Skip to content

Commit 9212119

Browse files
fix(components): a record page's stuck tab strip is a solid bar, flush with the page top (#35501)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg6v19uPsX6gX42G8tGcvvzb)_ Fixes #35414 repo:objectstack#5 · os-bill · session_01Utp6CbSphdunq2aJq7ktuY Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户看到的变化:在记录页向下滚动时,吸在顶部的「明细 / 相关 / 互动」页签条是实底(与页面底色一致,浅色深色主题各用自己的底色),下边线保留;下面滚过的卡片不再透出来压在页签文字上,页签条上方也不再露出一截滚过的内容。 - 为什么:原来页签条是半透明加模糊,而且停在离页面顶边还有一段距离的位置,滚动时内容与页签文字叠在一起,深色主题下尤其明显。 - 如果判断错:只影响页签条吸顶时的底色和停靠位置;页签样式、顺序、竖排页签都不变,最坏情况是吸顶位置与原来一样。 - 需要您做的:无。 ## What changes All in the `page:tabs` renderer (`containers.tsx`), horizontal strips only. - **Solid fill.** The stuck strip's classes go from `sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60` to `sticky top-0 z-20 bg-background`: the theme token with no alpha and no blur, so the dark theme gets its own page colour from the same token (no hard-coded colour). The bottom rule (the strip's inset shadow) is untouched; tab style, order and vertical tabs are untouched. - **The strip above it — the cause.** The record page's scroller is padded (`p-3 sm:p-4 lg:p-6` on the page scroller in `RecordDetailView`). Chromium sticks a `top: 0` box at the scroll container's padding edge, not its visible edge, so the stuck strip hung 12 to 24px below the top and the cards scrolling past showed in that gap. Measured in the preinstalled Chromium on a 24px-padded scroller scrolled 600px: scroller top 50, sticky box top 74 with `top: 0`; 50 and 50 with `top: -24px`. - **The fix for it, without moving other layouts.** A small hook, `useStickyTopInset`, finds the strip's sticky scroll container (the nearest ancestor whose overflow is not visible or clip, the same box the browser sticks it in) and sets the strip's `top` to minus that container's top padding, re-read on the container's resize and on window resize (the padding changes at breakpoints). An unpadded host, or a page that scrolls at the document root, measures 0 and the strip keeps plain `top-0`, so nothing moves there. Before the first measure the strip is at today's `top-0`. The offset only applies while the strip is stuck; at rest the strip is where it was. The page scroller itself is not edited. ## Tests <details><summary>Pins (a new top-level describe in the existing strip harness)</summary> `page-tabs-overflow-cue-27521.test.tsx`, describe "the stuck strip is a solid bar flush with its scroller top": - the horizontal strip carries `sticky`, `top-0`, `z-20`, `bg-background`, no alpha-suffixed `bg-background` class, no `backdrop` class, and keeps its bottom-rule shadow; - inside a scroller with 24px top padding the strip's `top` is `-24px`; - after the scroller's padding becomes 12px and the window resizes, `top` is `-12px`; - CONTROL: an unpadded scroller leaves `top` unset; - CONTROL: a vertical strip is never sticky and never offset. The file also gains the module-top `import '@object-ui/react-runtime'` that `check:test-source-alias` prescribed for an edited harness reaching `react-page`. </details> <details><summary>Runs</summary> - Dependency closure: `pnpm --workspace-concurrency=2 --filter '@object-ui/components^...' build` → lock `VERDICT command-exit 0`. - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/components/` then `pnpm --filter @object-ui/components run type-check` (tree 7de836e) → `Test Files 487 passed | 1 skipped (488)`, `Tests 4671 passed | 24 skipped (4695)`, type-check script echoed, lock `VERDICT command-exit 0`. - The harness file at head 14bc269 → `Tests 8 passed (8)`, lock `VERDICT command-exit 0`. - Ablation (fix committed, `scripts/ablation-replace.mjs`, each leg restored to the HEAD blob with `git diff HEAD` empty): the `top` style removed → the 24px and resize pins fail (`2 failed | 6 passed`); the old translucent blurred class put back → the solid-fill pin fails (`1 failed | 7 passed`). </details> ## Acceptance notes - When a strip has more tabs than fit, its existing edge-fade cue is a `mask-image` on the strip itself, so in that fade band (2.5rem at the hidden edge) the fill fades too and content under a stuck strip can show through there. Desktop record pages with three tabs do not overflow; the cue is not changed here. Noted, not filed. - The card's other observation, that the strip spans only the left column while the right column keeps scrolling beside it, is not in this card's two items and is unchanged. - The live record page in the running console was not driven in this run; the geometry was read in real Chromium on a padded scroller (above), and the pins drive the real renderer. ## Verification <details><summary>Gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands` (tree 7de836e): 38 families, each run with its exit code recorded. `check:test-source-alias` was red once (exit 1, the module-top import above) and is green (exit 0) at 14bc269; the other 37 exit 0. `--ran` reconciliation: `38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero ...)`. - `pnpm check:new-line-citations` → `0 new citation(s)`. - `node scripts/pm/overlap-check.mjs --branch=HEAD` → `VERDICT clean`. - The wider run (lint, UI typecheck, full UI test shards, E2E, dogfood) is left to CI. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 578d3b1 commit 9212119

3 files changed

Lines changed: 140 additions & 2 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/components': patch
3+
---
4+
5+
fix(components): a record page's stuck tab strip is a solid bar, flush with the top of the page
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
On a long record page the horizontal tab strip (Details / Related / Activity) sticks to the top as you scroll. Its fill was 60% transparent with a blur, so the cards scrolling under it showed through and overlapped the tab labels, worst in the dark theme. It also stopped short of the top: the page's scroll area is padded, and the browser sticks a `top: 0` box at the padding's inner edge, so a strip of scrolled content stayed visible above the tabs. The stuck strip now uses the solid page-background colour of the active theme and keeps its bottom rule, and it stops exactly at the visible top of its scroll area, whatever that area's padding at the current screen width. Vertical (sidebar) tab layouts, tab styles and tab order are unchanged.

‎ui/packages/components/src/__tests__/page-tabs-overflow-cue-27521.test.tsx‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { act, fireEvent, render } from '@testing-library/react';
1919
import React from 'react';
2020
import { SchemaRenderer } from '@object-ui/react';
2121
import '../renderers';
22+
// `react-page` reaches this dynamically; load it during collection, not in a
23+
// clocked case (`check:test-source-alias`).
24+
import '@object-ui/react-runtime';
2225

2326
const TABS = ['Details', 'Positions', 'Permission Sets', 'Sessions'].map((label) => ({
2427
label,
@@ -70,3 +73,55 @@ describe('page:tabs — the strip scrolls and cues its hidden edge (objectstack#
7073
expect(el.className).not.toContain('overflow-x-auto');
7174
});
7275
});
76+
77+
/** The strip rendered inside a scroll container with the given top padding. */
78+
function stripInScroller(paddingTop: string, position?: 'left') {
79+
const { container } = render(
80+
<div data-testid="scroller" style={{ overflowY: 'auto', paddingTop }}>
81+
<SchemaRenderer schema={{ type: 'page:tabs', items: TABS, ...(position ? { position } : {}) } as never} />
82+
</div>,
83+
);
84+
return {
85+
scroller: container.querySelector('[data-testid="scroller"]') as HTMLElement,
86+
el: container.querySelector('[role="tablist"]') as HTMLElement,
87+
};
88+
}
89+
90+
describe('page:tabs — the stuck strip is a solid bar flush with its scroller top (objectstack#35414)', () => {
91+
it('the horizontal strip sticks with the solid page-background token: no transparency, no blur', () => {
92+
const el = strip();
93+
const classes = el.className.split(/\s+/);
94+
expect(classes).toEqual(expect.arrayContaining(['sticky', 'top-0', 'z-20', 'bg-background']));
95+
// Neither an alpha-suffixed fill nor a blur may come back: either lets the
96+
// content scrolling under the stuck strip show through its labels.
97+
expect(classes.filter((c) => c.includes('bg-background/'))).toEqual([]);
98+
expect(classes.filter((c) => c.includes('backdrop'))).toEqual([]);
99+
// The bottom rule stays.
100+
expect(el.className).toContain('shadow-[inset_0_-1px_0_var(--color-border)]');
101+
});
102+
103+
it("a padded scroller: the strip stops its padding above top-0, so no strip of content shows above it", () => {
104+
const { el } = stripInScroller('24px');
105+
expect(el.style.top).toBe('-24px');
106+
});
107+
108+
it('the inset is re-read when the scroller resizes (its padding changes at breakpoints)', () => {
109+
const { el, scroller } = stripInScroller('24px');
110+
scroller.style.paddingTop = '12px';
111+
act(() => {
112+
window.dispatchEvent(new Event('resize'));
113+
});
114+
expect(el.style.top).toBe('-12px');
115+
});
116+
117+
it('CONTROL: an unpadded scroller leaves the strip at top-0', () => {
118+
const { el } = stripInScroller('0px');
119+
expect(el.style.top).toBe('');
120+
});
121+
122+
it('CONTROL: a vertical strip is a sidebar, never sticky and never offset', () => {
123+
const { el } = stripInScroller('24px', 'left');
124+
expect(el.className).not.toContain('sticky');
125+
expect(el.style.top).toBe('');
126+
});
127+
});

‎ui/packages/components/src/renderers/layout/containers.tsx‎

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,63 @@ export function usePageTabCountReporter(): ((count: number) => void) | undefined
685685
return (count: number) => panel.report(token, count);
686686
}
687687

688+
/**
689+
* The element a `position: sticky` box sticks inside: its nearest ancestor
690+
* whose overflow is not `visible`/`clip` in either axis. `null` when the
691+
* page itself scrolls (the root has no padding to make up for).
692+
*/
693+
function stickyScrollContainer(el: HTMLElement): HTMLElement | null {
694+
for (let p = el.parentElement; p; p = p.parentElement) {
695+
if (p === document.body || p === document.documentElement) return null;
696+
const style = getComputedStyle(p);
697+
if (/auto|scroll|hidden|overlay/.test(`${style.overflowX} ${style.overflowY}`)) return p;
698+
}
699+
return null;
700+
}
701+
702+
/**
703+
* objectstack#35414 — how far ABOVE `top: 0` a sticky tab strip must stop so
704+
* it sits flush with the visible top of its scroll container.
705+
*
706+
* Chromium sticks a `top: 0` box at the scroll container's CONTENT edge, not
707+
* its visible edge: the record page's scroller is padded (`p-3 sm:p-4
708+
* lg:p-6`), so the stuck strip hung 12–24px below the top and the cards
709+
* scrolling past showed in the gap above it. The strip's `top` is the
710+
* negative of the container's top padding — 0 in an unpadded host, so
711+
* nothing moves there — and re-read whenever the container resizes (its
712+
* padding changes at breakpoints). Before the first measure the strip keeps
713+
* `top-0`, which is today's position.
714+
*/
715+
function useStickyTopInset<T extends HTMLElement>(
716+
enabled: boolean,
717+
): [(node: T | null) => void, number] {
718+
const [node, setNode] = React.useState<T | null>(null);
719+
const [inset, setInset] = React.useState(0);
720+
721+
React.useEffect(() => {
722+
if (!enabled || !node) return undefined;
723+
const scroller = stickyScrollContainer(node);
724+
if (!scroller) {
725+
setInset(0);
726+
return undefined;
727+
}
728+
const measure = () => {
729+
const top = Number.parseFloat(getComputedStyle(scroller).paddingTop);
730+
setInset(Number.isFinite(top) && top > 0 ? top : 0);
731+
};
732+
measure();
733+
const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
734+
observer?.observe(scroller);
735+
window.addEventListener('resize', measure);
736+
return () => {
737+
observer?.disconnect();
738+
window.removeEventListener('resize', measure);
739+
};
740+
}, [enabled, node]);
741+
742+
return [setNode, inset];
743+
}
744+
688745
/**
689746
* Whether a tab's subtree holds a `list-view` block, the block that reports its
690747
* count through {@link PageTabPanelCountContext}. Walks the same slots
@@ -1162,6 +1219,16 @@ const PageTabsRenderer: React.FC<any> = ({ schema, className, ...props }) => {
11621219
// A horizontal strip with more tabs than fit scrolls sideways, and fades at
11631220
// each edge that hides a tab, so the reader can tell the strip goes on.
11641221
const [stripRef, stripOverflow] = useHorizontalOverflow<HTMLDivElement>();
1222+
// objectstack#35414 — the stuck strip sits flush with its scroller's
1223+
// visible top (see `useStickyTopInset`).
1224+
const [stickyRef, stickyInset] = useStickyTopInset<HTMLDivElement>(!isVertical);
1225+
const stripNodeRef = React.useCallback(
1226+
(node: HTMLDivElement | null) => {
1227+
stripRef(node);
1228+
stickyRef(node);
1229+
},
1230+
[stripRef, stickyRef],
1231+
);
11651232

11661233
const listClass = cn(
11671234
isVertical && 'flex-col h-auto items-stretch p-1',
@@ -1182,7 +1249,12 @@ const PageTabsRenderer: React.FC<any> = ({ schema, className, ...props }) => {
11821249
// Pin the horizontal tab strip to the top of the scroll container so
11831250
// users keep their bearings on long record pages. Skipped for vertical
11841251
// layouts where the strip is a sidebar, not a header.
1185-
!isVertical && 'sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60',
1252+
// objectstack#35414 — a SOLID page-background fill: the translucent,
1253+
// blurred fill let the cards scrolling under the stuck strip show through
1254+
// and overlap the tab labels (worst in the dark theme). `bg-background` is
1255+
// the theme token, so dark mode gets its own page colour; the bottom rule
1256+
// (the inset shadow above) is untouched.
1257+
!isVertical && 'sticky top-0 z-20 bg-background',
11861258
);
11871259

11881260
const triggerClass = () => cn(
@@ -1232,9 +1304,10 @@ const PageTabsRenderer: React.FC<any> = ({ schema, className, ...props }) => {
12321304
schema?.alwaysShowStrip === true ||
12331305
schema?.properties?.alwaysShowStrip === true) && (
12341306
<TabsList
1235-
ref={isVertical ? undefined : stripRef}
1307+
ref={isVertical ? undefined : stripNodeRef}
12361308
data-overflow={isVertical ? undefined : stripOverflow}
12371309
className={listClass}
1310+
style={!isVertical && stickyInset > 0 ? { top: -stickyInset } : undefined}
12381311
>
12391312
{itemsWithValue.map((item) => (
12401313
<TabsTrigger key={item.value} value={item.value} className={triggerClass()}>

0 commit comments

Comments
 (0)