An open source design system that's fully customizable and agent ready
TypeScript
fix(Layer): stop an outer Stepper's connector gap at a layer content boundary (#7287)
Cindy Zhang684b56d19e18
diff --git a/.changeset/layer-stops-stepper-connector-gap.md b/.changeset/layer-stops-stepper-connector-gap.mdnew file mode 100644index 0000000000..6138236d1c--- /dev/null+++ b/.changeset/layer-stops-stepper-connector-gap.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] Stepper: a Stepper inside a layer opened from a step no longer picks up the outer Stepper's `--step-connector-gap`. Layer content roots (Popover and other `useLayer` surfaces, Dialog, BottomSheet, MobileNav, Lightbox, and the toast viewport) now stop that value, so the inner track starts from its `0px` default. Setting the gap on the inner Stepper or through the `stepper` theme target still works, and the gap still inherits normally outside layers.++@cixzhangdiff --git a/apps/storybook/stories/Stepper.stories.tsx b/apps/storybook/stories/Stepper.stories.tsxindex 299018f9bb..0c2829e8b2 100644--- a/apps/storybook/stories/Stepper.stories.tsx+++ b/apps/storybook/stories/Stepper.stories.tsx@@ -1,6 +1,6 @@// Copyright (c) Meta Platforms, Inc. and affiliates.-import {useState} from 'react';+import {useState, type CSSProperties} from 'react';import * as stylex from '@stylexjs/stylex';import type {Meta, StoryObj} from '@storybook/react';import {Stepper, Step} from '@astryxdesign/core/Stepper';@@ -9,6 +9,7 @@ import {Button} from '@astryxdesign/core/Button';import {Text} from '@astryxdesign/core/Text';import {Icon} from '@astryxdesign/core/Icon';import {Badge} from '@astryxdesign/core/Badge';+import {Popover} from '@astryxdesign/core/Popover';const meta: Meta<typeof Stepper> = {title: 'Core/Stepper',@@ -747,6 +748,47 @@ export const OnTrackVertical: Story = {},};+// The outer track holds its connectors 6px off each indicator. The popover is+// a layer opened from a step, so the Stepper inside it starts from its own 0px+// default: its connectors run into the indicators rather than copying the gap.+export const OnTrackGapInLayer: Story = {+ name: 'On-Track — Gap Stops at a Layer',+ render: () => {+ const [isOpen, setIsOpen] = useState(true);+ return (+ <div+ style={{maxWidth: 400, '--step-connector-gap': '6px'} as CSSProperties}>+ <Stepper+ activeStep={1}+ orientation="vertical"+ indicatorPosition="on-track">+ <Step step={0} label="Create workspace" />+ <Step step={1} label="Set up integrations">+ <Popover+ label="Integration steps"+ isOpen={isOpen}+ onOpenChange={setIsOpen}+ placement="end"+ content={+ <Stepper+ activeStep={1}+ orientation="vertical"+ indicatorPosition="on-track">+ <Step step={0} label="Connect" />+ <Step step={1} label="Map fields" />+ <Step step={2} label="Sync" />+ </Stepper>+ }>+ <Button label="Integration steps" variant="secondary" />+ </Popover>+ </Step>+ <Step step={2} label="Launch" />+ </Stepper>+ </div>+ );+ },+};+export const OnTrackHorizontal: Story = {name: 'On-Track — Horizontal',render: () => {diff --git a/docs/architecture/layer-runtime.md b/docs/architecture/layer-runtime.mdindex 7ac6ccfd6f..228a13beb9 100644--- a/docs/architecture/layer-runtime.md+++ b/docs/architecture/layer-runtime.md@@ -264,9 +264,9 @@ current `main`.### Layer content boundary — AST-038 implementation projection[AST-038](../specs/AST-038-layer-text-boundary/spec.md) owns the reading baseline-and surface/group boundary. This implementation resets layer-root text and whole-React contexts carrying surface/group membership; structural CSS isolation is-incomplete.+and surface/group boundary. This implementation resets layer-root text, whole+React contexts carrying surface/group membership, and named structural custom+properties; structural CSS isolation covers only the channels it names.The shared private text baseline is applied in both `useLayer` renderers and theDialog, Lightbox, MobileNav, BottomSheetPanel, and ToastViewport content roots.@@ -293,10 +293,14 @@ isolation for Drawer is not implemented: the private Core boundary is notavailable across that package boundary. This is a remaining package-architecturegap, not a claim of complete provider isolation.-Structural custom-property channels remain outside this implementation. A layer-opened from supported `Step.children` content can contain an inner Stepper that-still inherits the outer `--step-connector-gap`. React membership ends, but this-connector-layout inheritance remains a structural isolation gap.+The private structural reset sits beside the text baseline on the same content+roots and stops each structural custom property it names by setting it to+`initial`. It names `--step-connector-gap`, so an inner Stepper in a layer opened+from `Step.children` content starts from the connector's 0px fallback; a value+set on that Stepper, through its `stepper` target, or by a caller style on the+layer root still applies. It never resets by prefix, so theme tokens and writing+context keep inheriting. A structural channel it does not name still inherits+into layer content.Existing component behavior checks cover membership exit, explicit inner owners,unrelated context continuity, and state/focus retention. Browser evidence covers@@ -425,6 +429,9 @@ be updated only as that work ships.anchor/fixed/custom rendering, trigger source, and current same-gesture memory.- `Layer/layerHost.ts` owns safe inline versus nearest corrective portal placement.- `Layer/anchorName.ts` owns composition of anchor names on one trigger.+- `Layer/layerTextReset.stylex.ts` owns the text baseline and+ `Layer/layerStructureReset.stylex.ts` owns the named structural custom-property+ reset applied on layer content roots.- `Layer/layerViewportInset.stylex.ts` owns the gutter and the viewport caps;`Layer/layerSlideRules.ts` owns the slide options' `@position-try` rules;`LayerProvider` publishes the declared inset through `LayerContext`, anddiff --git a/packages/core/src/BottomSheet/BottomSheetPanel.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.tsxindex 201fee5e0d..ce92cb8b32 100644--- a/packages/core/src/BottomSheet/BottomSheetPanel.tsx+++ b/packages/core/src/BottomSheet/BottomSheetPanel.tsx@@ -50,6 +50,7 @@ import {import {mergeProps, themeProps} from '../utils';import {focusOutlineStyles} from '../utils/focusOutline.stylex';import {layerTextReset} from '../Layer/layerTextReset.stylex';+import {layerStructureReset} from '../Layer/layerStructureReset.stylex';import {LayerContentBoundary} from '../Layer/layerScopedContext';import {container} from '../Layout/container.stylex';import type {SpacingToken} from '../Layout/container.stylex';@@ -713,6 +714,7 @@ export function BottomSheetPanel({themeProps('bottom-sheet'),stylex.props(layerTextReset.reset,+ layerStructureReset.reset,styles.sheet,overlayPaddingReset.reset,height === 'hug' ? styles.hugHeight : styles.budget,diff --git a/packages/core/src/Dialog/Dialog.tsx b/packages/core/src/Dialog/Dialog.tsxindex 4364633486..f3898e68f5 100644--- a/packages/core/src/Dialog/Dialog.tsx+++ b/packages/core/src/Dialog/Dialog.tsx@@ -4,7 +4,7 @@/*** @file Dialog.tsx- * @input Uses React, DialogHTMLAttributes, ReactNode, container (Layout), DialogContext, layerTextReset+ * @input Uses React, DialogHTMLAttributes, ReactNode, container (Layout), DialogContext, layerTextReset, layerStructureReset* @output Exports Dialog component, DialogProps, DialogVariant, DialogPurpose types* @position Core implementation; consumed by index.ts, tested by Dialog.test.tsx*@@ -35,6 +35,7 @@ import type {BaseProps} from '../BaseProps';import * as stylex from '@stylexjs/stylex';import {useScrollLock} from '../hooks/useScrollLock';import {layerTextReset} from '../Layer/layerTextReset.stylex';+import {layerStructureReset} from '../Layer/layerStructureReset.stylex';import {LayerContentBoundary} from '../Layer/layerScopedContext';import {LayerDepthProvider} from '../Layer/LayerDepthContext';import {useLayerDismissal} from '../Layer/useLayerDismissal';@@ -679,6 +680,7 @@ export function Dialog({themeProps('dialog', {variant}),stylex.props(layerTextReset.reset,+ layerStructureReset.reset,styles.inlineWrapper,overlayPaddingReset.reset,standardSizing &&@@ -714,6 +716,7 @@ export function Dialog({themeProps('dialog', {variant}),focusOutlineProps.focusVisible(layerTextReset.reset,+ layerStructureReset.reset,styles.dialog,overlayPaddingReset.reset,isOpen && styles.open,diff --git a/packages/core/src/Layer/layerStructureReset.stylex.ts b/packages/core/src/Layer/layerStructureReset.stylex.tsnew file mode 100644index 0000000000..6c65b7da6a--- /dev/null+++ b/packages/core/src/Layer/layerStructureReset.stylex.ts@@ -0,0 +1,31 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file layerStructureReset.stylex.ts+ * @input Uses StyleX+ * @output Stops inherited structural custom properties at a layer's content boundary+ * @position Private Core styling; AST-038 FR7 owns the accepted contract+ */++import * as stylex from '@stylexjs/stylex';++/**+ * Apply beside `layerTextReset`, before component and consumer styles, on the+ * layer's content boundary. Top-layer promotion does not stop DOM inheritance,+ * so a structural value an ancestor component scoped to its own descendants+ * would otherwise reach unrelated content opened from inside it.+ *+ * Name each property: a structural channel stops here only once it is known.+ * Theme tokens and writing context must keep inheriting (AST-038 FR2), so this+ * never resets by prefix.+ */+export const layerStructureReset = stylex.create({+ reset: {+ // A Stepper reads its connector gap from the nearest ancestor that sets it,+ // so a Stepper opened in a layer from one of its steps would inherit the+ // outer track's gap. `initial` hands the connector back its own 0px+ // fallback. A value set on the inner Stepper, through its `stepper` theme+ // target, or by a caller style on this layer root still applies.+ '--step-connector-gap': 'initial',+ },+});diff --git a/packages/core/src/Layer/useLayer.tsx b/packages/core/src/Layer/useLayer.tsxindex d958dc0e4b..694e422902 100644--- a/packages/core/src/Layer/useLayer.tsx+++ b/packages/core/src/Layer/useLayer.tsx@@ -32,6 +32,7 @@ import {addAnchorName, removeAnchorName} from './anchorName';import {currentGesture, currentGestureHasClicked} from './gestureCounter';import {resolveLayerPortalTarget} from './layerHost';import {layerTextReset} from './layerTextReset.stylex';+import {layerStructureReset} from './layerStructureReset.stylex';import {layerViewportInset} from './layerViewportInset.stylex';import {layerInsetProperties} from './layerInset';import {@@ -1196,6 +1197,7 @@ function useLayerImplementation(const stylexResult = stylex.props(layerTextReset.reset,+ layerStructureReset.reset,styles.base,overlayPaddingReset.reset,viewportStyles,@@ -1271,6 +1273,7 @@ function useLayerImplementation(const stylexResult = stylex.props(layerTextReset.reset,+ layerStructureReset.reset,styles.base,overlayPaddingReset.reset,styles.fixed,diff --git a/packages/core/src/Lightbox/Lightbox.tsx b/packages/core/src/Lightbox/Lightbox.tsxindex 16c0473b8a..07e86f37e4 100644--- a/packages/core/src/Lightbox/Lightbox.tsx+++ b/packages/core/src/Lightbox/Lightbox.tsx@@ -4,7 +4,7 @@/*** @file Lightbox.tsx- * @input Uses React, native dialog, StyleX, IconButton, theme tokens, layerTextReset+ * @input Uses React, native dialog, StyleX, IconButton, theme tokens, layerTextReset, layerStructureReset* @output Exports Lightbox component, LightboxProps, LightboxMedia* @position Core implementation; consumed by index.ts*@@ -38,6 +38,7 @@ import type {BaseProps} from '../BaseProps';import {themeProps} from '../utils/themeProps';import {focusOutlineStyles} from '../utils/focusOutline.stylex';import {layerTextReset} from '../Layer/layerTextReset.stylex';+import {layerStructureReset} from '../Layer/layerStructureReset.stylex';import {LayerContentBoundary} from '../Layer/layerScopedContext';import {overlayPaddingReset} from '../Layout/padding.stylex';import {LayerDepthProvider} from '../Layer/LayerDepthContext';@@ -621,6 +622,7 @@ export function Lightbox({themeProps('lightbox'),stylex.props(layerTextReset.reset,+ layerStructureReset.reset,styles.dialog,overlayPaddingReset.reset,xstyle,diff --git a/packages/core/src/MobileNav/MobileNav.tsx b/packages/core/src/MobileNav/MobileNav.tsxindex 5f3c238911..c6c41c92f7 100644--- a/packages/core/src/MobileNav/MobileNav.tsx+++ b/packages/core/src/MobileNav/MobileNav.tsx@@ -59,6 +59,7 @@ import {} from '../hooks/scrollbarGutter';import {mergeProps, composeEventHandlers} from '../utils';import {layerTextReset} from '../Layer/layerTextReset.stylex';+import {layerStructureReset} from '../Layer/layerStructureReset.stylex';import {LayerContentBoundary} from '../Layer/layerScopedContext';import {overlayPaddingReset} from '../Layout/padding.stylex';import {LayerDepthProvider} from '../Layer/LayerDepthContext';@@ -595,6 +596,7 @@ export function MobileNav({themeProps('mobile-nav', {side: resolvedSide}),stylex.props(layerTextReset.reset,+ layerStructureReset.reset,styles.dialog,overlayPaddingReset.reset,isOpen && styles.open,diff --git a/packages/core/src/Stepper/Stepper.spec.md b/packages/core/src/Stepper/Stepper.spec.mdindex 0408f78673..e1a17519ab 100644--- a/packages/core/src/Stepper/Stepper.spec.md+++ b/packages/core/src/Stepper/Stepper.spec.md@@ -95,7 +95,7 @@ Consumer syntax and description remain in `Stepper.doc.mjs` `theming.vars`.| ID | Candidate invariant | Basis | Draft review state || ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | ------------------------- |-| FR1 | `--step-connector-gap` falls back to `0px` where each connector consumes it and honors values inherited from an ancestor or supplied through the `stepper` theming target. | Reviewed defect (PR #5495) | Settled |+| FR1 | `--step-connector-gap` falls back to `0px` where each connector consumes it and honors values inherited from an ancestor up to the nearest layer content boundary, or supplied through the `stepper` theming target. | Reviewed defect (PR #5495) | Settled || FR2 | The gap is applied to the ONE edge each segment faces the indicator from, mirrored per axis, so the pair leaves a hole centred on the node. | Current source and browser probe | Settled || FR3 | One declaration covers both connector paint layers. A clip on the segment clips its `::before` with it, against one reference box, so the two cannot disagree. | Current source and browser probe | Settled || FR4 | The resolved value is clamped to `max(0px, min(value, --spacing-2))` before use. | Reviewed defect (PR #5495) | Settled |diff --git a/packages/core/src/Stepper/Stepper.test.tsx b/packages/core/src/Stepper/Stepper.test.tsxindex be17c59b9b..6c7ece4fc6 100644--- a/packages/core/src/Stepper/Stepper.test.tsx+++ b/packages/core/src/Stepper/Stepper.test.tsx@@ -7,6 +7,7 @@ import userEvent from '@testing-library/user-event';import {Stepper} from './Stepper';import {Step} from './Step';import {useStepperContext} from './StepperContext';+import {useLayer} from '../Layer/useLayer';import {defineTheme} from '../theme/defineTheme';import {generateThemeCSS} from '../theme/generateThemeRules';@@ -1831,6 +1832,59 @@ describe('Stepper', () => {);});+ it('stops an outer gap at a layer opened from a step', async () => {+ // An outer Stepper's gap is scoped to its own track. A layer opened from+ // one of its steps is new content, so an inner Stepper there starts from+ // the connector's own 0px fallback (AST-038 FR7) instead of inheriting+ // the outer value through the DOM.+ function StepLayer() {+ const layer = useLayer({mode: 'context'});+ return (+ <>+ <button type="button" ref={layer.ref} onClick={layer.show}>+ Details+ </button>+ {layer.render(+ <Stepper activeStep={0} indicatorPosition="on-track">+ <Step step={0} label="Inner one" />+ <Step step={1} label="Inner two" />+ </Stepper>,+ )}+ </>+ );+ }+ const user = userEvent.setup();+ const {container} = render(+ <div style={{'--step-connector-gap': '6px'} as React.CSSProperties}>+ <Stepper activeStep={0} indicatorPosition="on-track">+ <Step step={0} label="Outer one">+ <StepLayer />+ </Step>+ <Step step={1} label="Outer two" />+ </Stepper>+ </div>,+ );+ await user.click(screen.getByRole('button', {name: 'Details'}));++ const layerRoot = container.querySelector('[popover]') as HTMLElement;+ expect(layerRoot).not.toBeNull();+ expect(declarationsFor(layerRoot)).toContain(+ '--step-connector-gap:initial',+ );++ // Ancestor inheritance still works outside the layer, and the inner+ // Stepper keeps the same inheriting root, so a value set on it or through+ // the `stepper` target still reaches its connectors.+ const [outerRoot, innerRoot] = [+ ...container.querySelectorAll<HTMLElement>('.astryx-stepper'),+ ];+ expect(layerRoot.contains(outerRoot)).toBe(false);+ expect(layerRoot.contains(innerRoot)).toBe(true);+ expect(declarationsFor(innerRoot)).toContain(+ '--step-connector-gap:inherit',+ );+ });+it('leaves the connector target itself free of a segment vocabulary', () => {// The pieces are an implementation of the on-track layout, not API: no// `data-segment`, and no bare `lead`/`rail`/`content` class that coulddiff --git a/packages/core/src/Toast/ToastViewport.tsx b/packages/core/src/Toast/ToastViewport.tsxindex 0a5cc10946..32bd28e73f 100644--- a/packages/core/src/Toast/ToastViewport.tsx+++ b/packages/core/src/Toast/ToastViewport.tsx@@ -30,6 +30,7 @@ import {mergeProps} from '../utils';import {INTERACTIVE_SELECTORS} from '../hooks/useClickableContainer';import {useAnnounce} from '../hooks/useAnnounce';import {layerTextReset} from '../Layer/layerTextReset.stylex';+import {layerStructureReset} from '../Layer/layerStructureReset.stylex';import {LayerContentBoundary} from '../Layer/layerScopedContext';import {ToastSurface} from './Toast';import {ToastContext, type ToastContextValue} from './ToastContext';@@ -626,6 +627,7 @@ export function ToastViewport({{...mergeProps(stylex.props(layerTextReset.reset,+ layerStructureReset.reset,styles.viewport,styles.viewportInlineSpan,posStyle,diff --git a/packages/core/src/theme/derivedVarRegistry.test.ts b/packages/core/src/theme/derivedVarRegistry.test.tsindex e32887cc56..a9eae14e26 100644--- a/packages/core/src/theme/derivedVarRegistry.test.ts+++ b/packages/core/src/theme/derivedVarRegistry.test.ts@@ -264,6 +264,9 @@ const CROSS_COMPONENT_VARS: Record<string, string[]> = {// The destructive item variant recolors the Item it renders; Item owns,// documents and reads both slots.DropdownMenu: ['--_item-label-color', '--_item-description-color'],+ // A layer content root stops an outer Stepper's connector gap; Stepper owns,+ // documents and reads it.+ Layer: ['--step-connector-gap'],};/**