An open source design system that's fully customizable and agent ready
TypeScript
fix(core): a Step keeps its own aria-current over a caller's (#10640)
Parinith859a6fdac293
diff --git a/.changeset/step-owns-aria-current.md b/.changeset/step-owns-aria-current.mdnew file mode 100644index 0000000000..259f53828c--- /dev/null+++ b/.changeset/step-owns-aria-current.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] A `Step` keeps its own `aria-current` over a caller's. Before, an `aria-current` passed to a `Step` replaced the reflected value, so a step that was not in progress could be marked current and the in-progress step could lose `aria-current="step"`. Now only the in-progress step carries `aria-current="step"`, whatever the caller passes. No API changes.++@parinith-webdiff --git a/packages/core/src/Stepper/Step.tsx b/packages/core/src/Stepper/Step.tsxindex 1cc223ddee..5005416a73 100644--- a/packages/core/src/Stepper/Step.tsx+++ b/packages/core/src/Stepper/Step.tsx@@ -1624,9 +1624,10 @@ export function Step({className,style,)}- aria-current={isActive ? 'step' : undefined}data-testid={dataTestId}- {...rest}>+ {...rest}+ // Keep this after `{...rest}` so a caller's `aria-current` cannot replace it.+ aria-current={isActive ? 'step' : undefined}>{hasButton ? (<buttontype="button"@@ -1720,9 +1721,10 @@ export function Step({className,style,)}- aria-current={isActive ? 'step' : undefined}data-testid={dataTestId}- {...rest}>+ {...rest}+ // Keep this after `{...rest}` so a caller's `aria-current` cannot replace it.+ aria-current={isActive ? 'step' : undefined}>{hasButton ? (<buttontype="button"@@ -1769,9 +1771,10 @@ export function Step({className,style,)}- aria-current={isActive ? 'step' : undefined}data-testid={dataTestId}- {...rest}>+ {...rest}+ // Keep this after `{...rest}` so a caller's `aria-current` cannot replace it.+ aria-current={isActive ? 'step' : undefined}>{/* 4px progress bar */}<div{...mergeProps(@@ -1837,9 +1840,10 @@ export function Step({className,style,)}- aria-current={isActive ? 'step' : undefined}data-testid={dataTestId}- {...rest}>+ {...rest}+ // Keep this after `{...rest}` so a caller's `aria-current` cannot replace it.+ aria-current={isActive ? 'step' : undefined}>{/* 4px progress bar segment for this step */}<div{...mergeProps(diff --git a/packages/core/src/Stepper/Stepper.test.tsx b/packages/core/src/Stepper/Stepper.test.tsxindex 63e4cb648f..bfd8c8a427 100644--- a/packages/core/src/Stepper/Stepper.test.tsx+++ b/packages/core/src/Stepper/Stepper.test.tsx@@ -57,6 +57,48 @@ describe('Stepper', () => {expect(screen.getByTestId('step-2')).not.toHaveAttribute('aria-current');});+ it.each([+ ['horizontal', 'separated'],+ ['vertical', 'separated'],+ ['horizontal', 'on-track'],+ ['vertical', 'on-track'],+ ] as const)(+ 'keeps aria-current on the in-progress step over a caller’s (%s, %s)',+ (orientation, indicatorPosition) => {+ render(+ <Stepper+ activeStep={1}+ orientation={orientation}+ indicatorPosition={indicatorPosition}>+ <Step+ step={0}+ label="Step 1"+ data-testid="step-0"+ aria-current="page"+ />+ <Step+ step={1}+ label="Step 2"+ data-testid="step-1"+ aria-current="false"+ />+ <Step+ step={2}+ label="Step 3"+ data-testid="step-2"+ aria-current="true"+ />+ </Stepper>,+ );+ expect(screen.getByTestId('step-0')).not.toHaveAttribute('aria-current');+ expect(screen.getByTestId('step-1')).toHaveAttribute(+ 'aria-current',+ 'step',+ );+ expect(screen.getByTestId('step-2')).not.toHaveAttribute('aria-current');+ },+ );+it('renders descriptions when provided', () => {render(<Stepper activeStep={0}>