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

[DataGrid] Fix the accessibility of the column menu #900

Merged
merged 4 commits into from
Jan 29, 2021

Conversation

zj9495
Copy link
Contributor

@zj9495 zj9495 commented Jan 22, 2021

Closes #882

event.preventDefault();
hideMenu();
}
},
[hideMenu],
);
return (
<MenuList id="menu-list-grow" onKeyDown={handleListKeyDown}>
<MenuList aria-labelledby={`menu-button-${currentColumn.field}`} autoFocus autoFocusItem id="menu-list-grow" onKeyDown={handleListKeyDown}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about the menu-button hardcoded prefix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dtassone thanks! any good suggestions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the id here necessary, maybe I'm not seeing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image
https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-links.html
This document clarifies that aria-labelledby must be an ID reference, so i added a id to the column header filter button, and then used this ID as the aria-labelledby attribute of the column header MenuList

Copy link
Member

@oliviertassinari oliviertassinari Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a useId() helper that can be imported to solve this problem, it's meant as a bridge until reactjs/rfcs#32 is resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some doubts about how I can share this id between these two components if I use useId()? should i store id in ColumnMenuState?

Copy link
Member

@oliviertassinari oliviertassinari Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, I would expect each button and menu to be rendered in the same component (duplicate for each column), so sharing the id should be possible because in the same scope.

It appears that we share the same menu instance between different columns. This is likely creating an issue with the animation open/close too.

@DanailH

This comment has been minimized.

@oliviertassinari oliviertassinari added accessibility a11y component: data grid This is the name of the generic UI component, not the React module! labels Jan 25, 2021
@oliviertassinari
Copy link
Member

Any update on this effort? What's the blocker?

@dtassone

This comment has been minimized.

@dtassone dtassone merged commit b36b7d2 into mui:master Jan 29, 2021
oliviertassinari added a commit that referenced this pull request Jan 30, 2021
@zj9495 zj9495 deleted the fix-column-menu branch February 7, 2021 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] The column menu isn't accessible
4 participants