Skip to content

Commit 480a7b6

Browse files
authored
fix(accordions): set inert for hidden Stepper content (#1982)
1 parent 2aba142 commit 480a7b6

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

packages/accordions/src/elements/stepper/components/Content.spec.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ describe('Content', () => {
5858
</Stepper.Step>
5959
</Stepper>
6060
);
61+
const visibleElement = queryByText('Blueberry');
62+
const hiddenElement = queryByText('Strawberry');
6163

62-
expect(queryByText('Blueberry')).toHaveAttribute('aria-hidden', 'false');
63-
expect(queryByText('Strawberry')).toHaveAttribute('aria-hidden', 'true');
64+
expect(visibleElement).toHaveAttribute('aria-hidden', 'false');
65+
expect(visibleElement).not.toHaveAttribute('inert');
66+
expect(hiddenElement).toHaveAttribute('aria-hidden', 'true');
67+
expect(hiddenElement).toHaveAttribute('inert');
6468
});
6569
});

packages/accordions/src/elements/stepper/components/Content.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const ContentComponent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElemen
1616

1717
return isHorizontal === false ? (
1818
<StyledContent ref={ref} $isActive={isActive} {...props}>
19-
<StyledInnerContent aria-hidden={!isActive}>{props.children}</StyledInnerContent>
19+
<StyledInnerContent aria-hidden={!isActive} inert={isActive ? undefined : ''}>
20+
{props.children}
21+
</StyledInnerContent>
2022
</StyledContent>
2123
) : null;
2224
}

packages/accordions/src/styled/stepper/StyledInnerContent.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ import { getLineHeight, retrieveComponentStyles, getColor } from '@zendeskgarden
1010

1111
const COMPONENT_ID = 'accordions.step_inner_content';
1212

13-
export const StyledInnerContent = styled.div.attrs<ThemeProps<DefaultTheme>>({
13+
interface IStyledInnerContentProps extends ThemeProps<DefaultTheme> {
14+
inert?: string;
15+
}
16+
17+
export const StyledInnerContent = styled.div.attrs({
1418
'data-garden-id': COMPONENT_ID,
1519
'data-garden-version': PACKAGE_VERSION
16-
})`
20+
})<IStyledInnerContentProps>`
1721
overflow: hidden;
1822
line-height: ${props => getLineHeight(props.theme.space.base * 5, props.theme.fontSizes.md)};
1923
color: ${({ theme }) => getColor({ theme, variable: 'foreground.default' })};

0 commit comments

Comments
 (0)