Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(lab): MobilePowerSearch's sticky sheet header stays above the rows scrolling under it (#8005)

Xinzi Zhouae842c82a418
diff --git a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsx b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsx
index b48107d2e1..8760bf6810 100644
--- a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsx
+++ b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsx
@@ -684,6 +684,38 @@ describe('MobilePowerSearch Filters sheet', () => {
// =============================================================================
describe('MobilePowerSearch Add filter', () => {
+ it('keeps the sticky header above the rows that scroll under it, without covering the grab handle', () => {
+ setup();
+ openAddFlow();
+ const title = within(sheet()).getByRole('heading', {name: 'Add filter'});
+ // The title sits in the sticky header; the header's parent is the sheet
+ // content wrapper.
+ let header: HTMLElement | null = title;
+ while (header && getComputedStyle(header).position !== 'sticky') {
+ header = header.parentElement;
+ }
+ expect(header).not.toBeNull();
+ const content = header!.parentElement!;
+ // jsdom resolves the injected StyleX rules: the header has a layer above
+ // the List rows (position: relative, z-index auto) that follow it...
+ expect(getComputedStyle(header!).zIndex).toBe('1');
+ // ...scoped to the sheet content, so the panel's grab handle (z-index 1,
+ // outside this wrapper) still paints above the header.
+ const rules: string[] = [];
+ for (const styleSheet of Array.from(document.styleSheets)) {
+ for (const rule of Array.from(styleSheet.cssRules)) {
+ rules.push(rule.cssText);
+ }
+ }
+ const isolated = Array.from(content.classList).some(className =>
+ rules.some(
+ text =>
+ text.includes(`.${className}`) && /isolation:\s*isolate/.test(text),
+ ),
+ );
+ expect(isolated).toBe(true);
+ });
+
it('opens directly to Add filter when no filters are selected', () => {
setup();
openSheet();
diff --git a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsx b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsx
index c7f1ac4ceb..6bf04325e5 100644
--- a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsx
+++ b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsx
@@ -294,17 +294,23 @@ const styles = stylex.create({
minHeight: 44,
},
// --- sheet shell ---------------------------------------------------------
+ // Scopes the sticky header's and footer's layer to this sheet's content:
+ // the List rows are `position: relative` and come after the header, so
+ // without a layer of its own the header is painted under the rows that
+ // scroll beneath it. Isolating the content keeps that z-index inside it, so
+ // the sheet's grab handle (z-index 1 on the panel, outside this wrapper)
+ // still paints above.
sheet: {
display: 'flex',
flexDirection: 'column',
minHeight: '100%',
+ isolation: 'isolate',
},
header: {
position: 'sticky',
insetBlockStart: 0,
- // 0, not higher: the sheet's grab handle is an absolutely positioned
- // sibling at z-index 1; anything above it paints the pill out.
- zIndex: 0,
+ // Above the rows that scroll under it, within the isolated sheet content.
+ zIndex: 1,
display: 'flex',
flexDirection: 'column',
gap: spacingVars['--spacing-3'],
@@ -341,7 +347,7 @@ const styles = stylex.create({
footer: {
position: 'sticky',
insetBlockEnd: 0,
- zIndex: 0,
+ zIndex: 1,
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',