Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inputRole prop for Select component #5768

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-bikes-complain.md
@@ -0,0 +1,5 @@
---
'react-select': minor
---

Added inputRole property for Select component, which provides a role attribute to the input element.
6 changes: 5 additions & 1 deletion packages/react-select/src/Select.tsx
Expand Up @@ -171,6 +171,8 @@ export interface Props<
inputValue: string;
/** The id of the search input */
inputId?: string;
/** The role of the search input */
inputRole?: string;
/** Define an id prefix for the select components e.g. {your-id}-value */
instanceId?: number | string;
/** Is the select value clearable */
Expand Down Expand Up @@ -297,6 +299,7 @@ export const defaultProps = {
isMulti: false,
isRtl: false,
isSearchable: true,
inputRole: 'combobox',
isOptionDisabled: isOptionDisabledBuiltin,
loadingMessage: () => 'Loading...',
maxMenuHeight: 300,
Expand Down Expand Up @@ -1601,6 +1604,7 @@ export default class Select<
isDisabled,
isSearchable,
inputId,
inputRole,
inputValue,
tabIndex,
form,
Expand All @@ -1623,7 +1627,7 @@ export default class Select<
'aria-label': this.props['aria-label'],
'aria-labelledby': this.props['aria-labelledby'],
'aria-required': required,
role: 'combobox',
role: inputRole,
...(menuIsOpen && {
'aria-controls': this.getElementId('listbox'),
'aria-owns': this.getElementId('listbox'),
Expand Down