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 aria attributes to dummy input #3090

Merged
merged 6 commits into from
Oct 4, 2019
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
5 changes: 5 additions & 0 deletions .changeset/real-suns-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Add aria attributes to dummy input
29 changes: 18 additions & 11 deletions packages/react-select/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,13 +918,19 @@ export default class Select extends Component<Props, State> {
this.openMenu('first');
}
} else {
//$FlowFixMe
if (event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') {
if (
// $FlowFixMe
event.target.tagName !== 'INPUT' &&
event.target.tagName !== 'TEXTAREA'
) {
this.onMenuClose();
}
}
//$FlowFixMe
if (event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') {
if (
// $FlowFixMe
event.target.tagName !== 'INPUT' &&
event.target.tagName !== 'TEXTAREA'
) {
event.preventDefault();
}
};
Expand Down Expand Up @@ -1397,6 +1403,13 @@ export default class Select extends Component<Props, State> {

const id = inputId || this.getElementId('input');

// aria attributes makes the JSX "noisy", separated for clarity
const ariaAttributes = {
'aria-autocomplete': 'list',
'aria-label': this.props['aria-label'],
'aria-labelledby': this.props['aria-labelledby'],
};

if (!isSearchable) {
// use a dummy input to maintain focus/blur functionality
return (
Expand All @@ -1410,17 +1423,11 @@ export default class Select extends Component<Props, State> {
disabled={isDisabled}
tabIndex={tabIndex}
value=""
{...ariaAttributes}
/>
);
}

// aria attributes makes the JSX "noisy", separated for clarity
const ariaAttributes = {
'aria-autocomplete': 'list',
'aria-label': this.props['aria-label'],
'aria-labelledby': this.props['aria-labelledby'],
};

const { cx, theme, selectProps } = this.commonProps;

return (
Expand Down