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 id attribute to match aria-owns attribute #15564

Merged
merged 2 commits into from
May 13, 2019
Merged
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
12 changes: 8 additions & 4 deletions packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ class URLInput extends Component {
render() {
const { value = '', autoFocus = true, instanceId, className } = this.props;
const { showSuggestions, suggestions, selectedSuggestion, loading } = this.state;

const suggestionsListboxId = `block-editor-url-input-suggestions-${ instanceId }`;
const suggestionOptionIdPrefix = `block-editor-url-input-suggestion-${ instanceId }`;

/* eslint-disable jsx-a11y/no-autofocus */
return (
<div className={ classnames( 'editor-url-input block-editor-url-input', className ) }>
Expand All @@ -242,8 +246,8 @@ class URLInput extends Component {
role="combobox"
aria-expanded={ showSuggestions }
aria-autocomplete="list"
aria-owns={ `block-editor-url-input-suggestions-${ instanceId }` }
aria-activedescendant={ selectedSuggestion !== null ? `block-editor-url-input-suggestion-${ instanceId }-${ selectedSuggestion }` : undefined }
aria-owns={ suggestionsListboxId }
aria-activedescendant={ selectedSuggestion !== null ? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }` : undefined }
ref={ this.inputRef }
/>

Expand All @@ -253,7 +257,7 @@ class URLInput extends Component {
<Popover position="bottom" noArrow focusOnMount={ false }>
<div
className="editor-url-input__suggestions block-editor-url-input__suggestions"
id={ `editor-url-input-suggestions-${ instanceId }` }
id={ suggestionsListboxId }
ref={ this.autocompleteRef }
role="listbox"
>
Expand All @@ -262,7 +266,7 @@ class URLInput extends Component {
key={ suggestion.id }
role="option"
tabIndex="-1"
id={ `block-editor-url-input-suggestion-${ instanceId }-${ index }` }
id={ `${ suggestionOptionIdPrefix }-${ index }` }
ref={ this.bindSuggestionNode( index ) }
className={ classnames( 'editor-url-input__suggestion block-editor-url-input__suggestion', {
'is-selected': index === selectedSuggestion,
Expand Down