Skip to content
Closed
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
3 changes: 3 additions & 0 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ type FormatOptionLabelMeta = {
};

export type Props = {
/* HTML ID of an element that should be used to describe this input (for assistive tech) */
'aria-describedby'?: string,
/* Aria label (for assistive tech) */
'aria-label'?: string,
/* HTML ID of an element that should be used as the label (for assistive tech) */
Expand Down Expand Up @@ -1399,6 +1401,7 @@ export default class Select extends Component<Props, State> {
// aria attributes makes the JSX "noisy", separated for clarity
const ariaAttributes = {
'aria-autocomplete': 'list',
'aria-describedby': this.props['aria-describedby'],
'aria-label': this.props['aria-label'],
'aria-labelledby': this.props['aria-labelledby'],
};
Expand Down
20 changes: 20 additions & 0 deletions src/__tests__/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,26 @@ cases(
}
);

cases(
'accessibility > passes through aria-describedby prop',
({ props = { ...BASIC_PROPS, 'aria-describedby': 'testing' } }) => {
let selectWrapper = mount(<Select {...props} />);
expect(selectWrapper.find('Control input').props()['aria-describedby']).toBe(
'testing'
);
},
{
'single select > should pass aria-describedby prop down to input': {},
'multi select > should pass aria-describedby prop down to input': {
props: {
...BASIC_PROPS,
'aria-describedby': 'testing',
isMulti: true,
},
},
}
);

cases(
'accessibility > passes through aria-labelledby prop',
({ props = { ...BASIC_PROPS, 'aria-labelledby': 'testing' } }) => {
Expand Down