-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Reuse the menu pane component for dropdown select options #17271
Reuse the menu pane component for dropdown select options #17271
Conversation
@@ -20,16 +23,19 @@ interface IDropdownSelectButtonProps<T extends string> { | |||
readonly options: ReadonlyArray<IDropdownSelectButtonOption<T>> | |||
|
|||
/** The selection option value */ | |||
readonly selectedValue?: T | |||
readonly checkedOption?: T |
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.
Since the menu items uses the term "selected" to denote the "Highlighted" or "Focused" value, I changed this to "checked" to make that distinction clearer.
When the menu closes, as important for accessibility, it returns focus to the dropdown button. This is how it is programmed and works for the suggested next actions and the merge options in the compare branch feature. However, for the merge, squash merge, and rebase dialog, the dialog is actually re-rendered when switching between rebase and one of the other two options. Thus, the focus is reset to the filter. This will take a little rework of the multi commit operation handling of that first step of those operations to fix. I will address in another PR. Expected behavior: Screen.Recording.2023-08-23.at.5.06.59.PM.movBug: Screen.Recording.2023-08-23.at.5.08.20.PM.mov |
This reverts commit 2b2596a.
@@ -161,6 +178,13 @@ export class MenuListItem extends React.Component<IMenuListItemProps, {}> { | |||
selected: this.props.selected, | |||
}) | |||
|
|||
const role = this.props.hasNoRole | |||
? undefined | |||
: type === 'checkbox' |
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.
So.. this should probably be the radio one... but it uses the wrong icon. :/ May circle back and allow for a custom icon.
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.
Amazing refactor!! Great work!!! 👏
It looks good to me, only found a few nits, and testing worked as expected, I couldn't detect regressions on menus.
I will approve the PR in case you decide to not to accept my suggestions or to do so in a different PR.
Co-authored-by: Sergio Padrino <sergio.padrino@gmail.com>
Co-authored-by: Sergio Padrino <sergio.padrino@gmail.com>
Co-authored-by: Sergio Padrino <sergio.padrino@gmail.com>
Co-authored-by: Sergio Padrino <sergio.padrino@gmail.com>
Supersedes #17231.
xref. https://github.com/github/accessibility-audits/issues/4936
Description
This PR aims to make the dropdown select button meet the accessibility criteria described in the W3C Action Menu Button Example
I first start to simply change it to use
ul
and ali
and knew that a lot of this logic was already done in our windows app menu components and so I started stealing bits of logic till I determined that I could probably just reuse theMenuPane
component. That is what this PR does and voila I got the vast majority of keyboard we needed from that.That is:
There is a on pane keydown handler to allowed me to easily add the "Escape" to close the menu and set focus to the dropdown button.
Things I have added to the dropdown select component:
Things added to the menu pane and menu list item
Checkbox
use the role "menuitemradio".Other thoughts:
IDropdownSelectButtonOption
feels like another abstraction that is being translated into aMenuItem
.. maybe I should refactor one step more and just make it so the options areMenuItem
, or make it extend theMenuItem
. But, not sure if it is worth changing more stuff..Screenshots
This video goes side by side down through the criteria in W3C Action Menu Button Example and demonstrates it with a key caster on.
Screen.Recording.2023-08-23.at.4.51.55.PM.mov
Things not highlighted in the video:
aria-label
- the criteria saysaria-labelledby
but there is no element with a label to apply heremenuitem
to the items. We usemenuitemradio
as one the menu items is marked as checked. It has thearia-checked
applied to it.Release notes
Notes: [Improved] Improve accessibility of dropdown select buttons