Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/slow-rocks-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': minor
'polaris.shopify.com': patch
---

Updated `Box` and `AlphaStack` to accept aria attributes
7 changes: 6 additions & 1 deletion polaris-react/src/components/AlphaStack/AlphaStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Element = 'div' | 'ul' | 'ol' | 'fieldset';

type Gap = ResponsiveProp<SpacingSpaceScale>;

export interface AlphaStackProps {
export interface AlphaStackProps extends React.AriaAttributes {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL 🌟

children?: React.ReactNode;
/** HTML Element type
* @default 'div'
Expand All @@ -34,6 +34,8 @@ export interface AlphaStackProps {
* @default '4'
*/
gap?: Gap;
/** HTML id attribute */
id?: string;
}

export const AlphaStack = ({
Expand All @@ -42,6 +44,8 @@ export const AlphaStack = ({
align = 'start',
fullWidth = false,
gap = '4',
id,
...restProps
}: AlphaStackProps) => {
const className = classNames(
styles.AlphaStack,
Expand All @@ -59,6 +63,7 @@ export const AlphaStack = ({
{
className,
style: sanitizeCustomProperties(style),
...restProps,
},
children,
);
Expand Down
4 changes: 3 additions & 1 deletion polaris-react/src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type BackgroundColors =
| ColorsActionTokenAlias
| ColorsSurfaceTokenAlias;

export interface BoxProps {
export interface BoxProps extends React.AriaAttributes {
children?: React.ReactNode;
/** HTML Element type
* @default 'div'
Expand Down Expand Up @@ -216,6 +216,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
insetInlineEnd,
zIndex,
opacity,
...restProps
},
ref,
) => {
Expand Down Expand Up @@ -326,6 +327,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
id,
ref,
style: sanitizeCustomProperties(style),
...restProps,
},
children,
);
Expand Down
13 changes: 13 additions & 0 deletions polaris-react/src/components/Box/tests/Box.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,17 @@ describe('Box', () => {
}) as React.CSSProperties,
});
});

it('renders the aria attributes that matches the aria attributes passed in', () => {
const box = mountWithApp(
<Box aria-required aria-describedby="test">
{children}
</Box>,
);

expect(box).toContainReactComponent('div', {
'aria-required': true,
'aria-describedby': 'test',
});
});
});
Loading