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

Fix null aria attributes #600

Merged
merged 2 commits into from
Jan 15, 2024
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
2 changes: 1 addition & 1 deletion dist/accessible-autocomplete.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/accessible-autocomplete.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.preact.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.preact.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.react.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.react.min.js.map

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions src/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,13 @@ export default class Autocomplete extends Component {
: ''

const assistiveHintID = id + '__assistiveHint'
const ariaDescribedProp = (ariaHint)
? {
'aria-describedby': assistiveHintID
}
: null
const ariaProps = {
'aria-describedby': ariaHint ? assistiveHintID : null,
'aria-expanded': menuOpen ? 'true' : 'false',
'aria-activedescendant': optionFocused ? `${id}__option--${focused}` : false,
'aria-owns': `${id}__listbox`,
'aria-autocomplete': (this.hasAutoselect()) ? 'both' : 'list'
}

let dropdownArrow

Expand Down Expand Up @@ -509,11 +511,7 @@ export default class Autocomplete extends Component {
)}

<input
aria-expanded={menuOpen ? 'true' : 'false'}
aria-activedescendant={optionFocused ? `${id}__option--${focused}` : false}
aria-owns={`${id}__listbox`}
aria-autocomplete={(this.hasAutoselect()) ? 'both' : 'list'}
{...ariaDescribedProp}
{...ariaProps}
autoComplete='off'
className={inputClassList.join(' ')}
id={id}
Expand Down