Skip to content

Commit 32d0f97

Browse files
author
Kubit
committed
Add new aria-props to PillSelector component
1 parent d469079 commit 32d0f97

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

src/components/pillSelector/pillSelectorStandAlone.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react';
33
import { Pill } from '@/components/pill';
44
import { useRoveFocus } from '@/hooks';
55
import { ROLES } from '@/types';
6+
import { pickAriaProps } from '@/utils';
67

78
import { PillSelectorWrapper, ThumbStyled } from './pillSelector.styled';
89
import type { IPillSelectorStandAlone } from './types';
@@ -14,6 +15,8 @@ const PillSelectorStandAloneComponent = (
1415
{ dataTestId, maxPills = MAX_PILLS, ...props }: IPillSelectorStandAlone,
1516
ref: React.ForwardedRef<HTMLDivElement>
1617
): React.JSX.Element => {
18+
const ariaProps = pickAriaProps(props);
19+
1720
const roveFocusProps = React.useMemo(
1821
() => ({
1922
size: props.pills.length,
@@ -36,6 +39,7 @@ const PillSelectorStandAloneComponent = (
3639

3740
return (
3841
<PillSelectorWrapper
42+
{...ariaProps}
3943
ref={listEl as React.RefObject<HTMLDivElement>}
4044
data-testid={`${dataTestId}PillSelector`}
4145
hasThumb={!!(!props.multiSelect && props.styles?.thumb)}

src/components/pillSelector/stories/argtypes.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,50 @@ export const argtypes = (
115115
category: CATEGORY_CONTROL.TESTING,
116116
},
117117
},
118+
['aria-label']: {
119+
description: 'Aria label of the button',
120+
type: { name: 'string' },
121+
control: { type: 'text' },
122+
table: {
123+
type: {
124+
summary: 'string',
125+
},
126+
category: CATEGORY_CONTROL.ACCESIBILITY,
127+
},
128+
},
129+
['aria-describedby']: {
130+
description: 'Aria text that should be read when the button is focused',
131+
type: { name: 'string' },
132+
control: { type: 'text' },
133+
table: {
134+
type: {
135+
summary: 'string',
136+
},
137+
category: CATEGORY_CONTROL.ACCESIBILITY,
138+
},
139+
},
140+
['aria-labelledby']: {
141+
description: 'Aria labelledby',
142+
type: { name: 'string' },
143+
control: { type: 'text' },
144+
table: {
145+
type: {
146+
summary: 'string',
147+
},
148+
category: CATEGORY_CONTROL.ACCESIBILITY,
149+
},
150+
},
151+
['aria-disabled']: {
152+
description: 'Aria for disabled buttons',
153+
type: { name: 'boolean' },
154+
control: { type: 'boolean' },
155+
table: {
156+
type: {
157+
summary: 'boolean',
158+
},
159+
category: CATEGORY_CONTROL.ACCESIBILITY,
160+
},
161+
},
118162
ctv: {
119163
description: 'Object used for update variant styles',
120164
control: { type: 'object' },

src/components/pillSelector/stories/pillSelector.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Story = StoryObj<typeof meta> & { args: { themeArgs?: object } };
2828

2929
export const PillSelector: Story = {
3030
args: {
31+
['aria-label']: 'Aria label pill selector',
3132
dataTestId: 'dataTestId',
3233
multiSelect: false,
3334
variant: Object.values(variantsObject[themeSelected].PillSelectorVariant || {})[0] as string,

src/components/pillSelector/types/pillSelector.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { CustomTokenTypes } from '@/types';
55

66
import { PillSelectorStyles } from './pillSelectorTheme';
77

8+
type PillSelectorAriaAttributes = Pick<
9+
React.AriaAttributes,
10+
'aria-label' | 'aria-labelledby' | 'aria-describedby' | 'aria-disabled'
11+
>;
12+
813
export type PillType = Pick<
914
IPillUnControlled,
1015
| 'disabled'
@@ -25,7 +30,7 @@ type PillSelectedType = number | string;
2530

2631
type Pill = Omit<PillType, 'size'> & { size?: string };
2732

28-
export interface IPillSelectorStandAlone {
33+
export interface IPillSelectorStandAlone extends PillSelectorAriaAttributes {
2934
pillVariant: string;
3035
pillSize?: string;
3136
pillSelected?: PillSelectedType[];

0 commit comments

Comments
 (0)