-
Notifications
You must be signed in to change notification settings - Fork 2.2k
MenuItem and QueryList ScreenReader Accessibility Improvements #7543
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
base: develop
Are you sure you want to change the base?
MenuItem and QueryList ScreenReader Accessibility Improvements #7543
Conversation
Generate changelog in
|
Remove redundant optionalityBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Merge branch 'develop' into cmcdougall/accessibility_changes_menu_itemBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused as to what the specific accessibility improvements here are. Can you provide some examples of what you're trying to achieve?
Generally supportive of allowing id to be passed on to MenuItem and for setting aria-activedescendant (though I have questions regarding how this is currently implemented).
| { handleClick, handleFocus, modifiers, query, ref }: ItemRendererProps, | ||
| ): MenuItemProps & React.Attributes { | ||
| itemProps: ItemRendererProps, | ||
| ): Omit<MenuItemProps, "key"> & React.Attributes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're omitting key from MenuItemProps for the return type, we should also remove React.Attributes since the intersection of that type just ends up adding it back:
interface Attributes {
key?: Key | null | undefined;
}| ): Omit<MenuItemProps, "key"> & React.Attributes { | |
| ): Omit<MenuItemProps, "key"> { |
I'm supportive of this fix for the docs examples, but could we split that part out into its own PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, thank you. I mostly am keeping in the docs examples as it is useful for my testing. Unless I'm not supposed to test on the docs examples? What is the better way to test?
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as React from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This React import can be removed:
| import * as React from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove thank you
| super(props); | ||
|
|
||
| // Generate unique ID for accessibility | ||
| this.listId = props.listId ?? `bp5-query-list-${Utils.uniqueId("ql")}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest removing the hardcoded version prefix and replacing with the following:
| this.listId = props.listId ?? `bp5-query-list-${Utils.uniqueId("ql")}`; | |
| this.listId = props.listId ?? Utils.uniqueId("bp-query-list"); |
| // When input gains focus, we don't immediately set visual focus state | ||
| // Visual focus state is only set when the user navigates with arrow keys | ||
| // This ensures screen readers only announce activedescendant when appropriate | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we defining this empty focus event handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this, will remove thank you!
| menuProps: { | ||
| ...menuProps, | ||
| id: this.listId, | ||
| role: "listbox", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default itemListRenderer implementation already includes this role. Do we need to include it again here?
| <Menu role="listbox" {...listProps.menuProps} ulRef={listProps.itemsParentRef}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove thank you
| menuProps, | ||
| menuProps: { | ||
| ...menuProps, | ||
| id: this.listId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| const input = ( | ||
| <InputGroup | ||
| aria-activedescendant={listProps.activeItemId} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we setting aria-activedescendant on the filter input group? Shouldn't we be setting this on the outermost combobox element?
Here's the WAI Select-Only Combobox Example for reference:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aria-activedescendant is on the InputGroup because that's the element that has keyboard focus when users navigate the options with arrow keys. The outermost combobox element loses focus once the popover opens and the InputGroup is focused. Happy to revise if this doesn't make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved the other aria details to the InputGroup now to be consistent
Address PR feedbackBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Remove redundant handleInputFocusBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Fix voiceOver getting confused when text rerendersBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |


Fixes #0000
Checklist
Changes proposed in this pull request:
ScreenReader accessibility improvements for the ItemRenderer, MenuItem, QueryList and Select components
Added proper ARIA relationships and controls:
Improved focus management in QueryList:
Updated films example:
Reviewers should focus on:
Ensuring this allows for backwards compatibility with other users of the component.
Screenshot