-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[MenuList] Fix keyboard a11y when no item is focused when opening #16323
Conversation
If it happens in a passive effect it happend after a commit. A render is only a call to the render function
}); | ||
}); | ||
|
||
describe('MenuList with focusable divider', () => { |
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.
While the implementation does allow this I don't think we should test those. After all this does seem invalid. See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex#Accessibility_concerns
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.
My intent wasn't really to support focusable dividers, but rather to demonstrate focus management working for something that isn't a MenuItem but still meets the rules for recognizing it as a non-disabled, focusable child of the list. I still think there is value in the intent of this test, though it might be better to use something other than Divider for demonstrating it.
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 cautious about opening this up to other components as well before we have a concrete use case. Especially since there is quite some movement in the react core with Flare and I would hope we'll be able to fully utilize their new event system without having to support other APIs.
Details of bundle changes.Comparing: 6a1bf86...dc8a4b9
|
Couldn't verify it manually in browserstack. Will investigate what the issue is. |
I've looked through the implementation changes and they make sense to me. I've taken a brief look at the tests. I'm a big fan of switching to using react-testing-library and dispatching the events in a more appropriate way. I'll find some time later today to look through the test changes in more detail. |
}); | ||
}); | ||
|
||
describe('MenuList with focusable divider', () => { |
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.
My intent wasn't really to support focusable dividers, but rather to demonstrate focus management working for something that isn't a MenuItem but still meets the rules for recognizing it as a non-disabled, focusable child of the list. I still think there is value in the intent of this test, though it might be better to use something other than Divider for demonstrating it.
@@ -15,210 +16,170 @@ function FocusOnMountMenuItem(props) { | |||
return <MenuItem {...props} ref={listItemRef} tabIndex={0} />; | |||
} | |||
|
|||
function TrackRenderCountMenuItem({ actions, ...other }) { | |||
const renderCountRef = React.useRef(0); | |||
function TrackCommitCountMenuItem({ actions, ...other }) { |
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 excited about a stable Profiler component where we can get rid of these workarounds.
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.
Get rid of it?!! I'm rather emotionally attached to that bit of code after all the time I invested into figuring out how to verify that it wasn't re-rendering on focus changes. :)
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.
Well this particular code is already nice because you went with commit tracking instead of the render tracking. That's already future proof when we run fuzzy tests in concurrent mode. Most of the tests around this issue go with render counting which will become unstable.
68736da
to
662d100
Compare
3ac82c4
to
916aa7d
Compare
916aa7d
to
dc8a4b9
Compare
The keyboard interaction doesn't seem to work on https://material-ui.com/components/menus/#simple-menu. Is this expected? |
Yes. This only fixed the integration with Select. The menu needs an a11y overhaul but I want to draft a general a11y proposal since the increasing discussions around a11y slows down work to the point where it's no longer viable. We need to find a general consensus how important a11y is for us first. |
@eps1lon I think that It largely depends on what aspect of a11y and how we want to grow the library. The majority of our current users don't truly care about it. It's what we have learned from the user survey. What people value is: features. The majority of our users use Material-UI to go fast. a11y is structurally in opposition with this objective, it's a lot of work. It's not necessary to validate business assumptions when building a prototype. It has a negative ROI on small projects. However, and that the interesting part, I think that there is an opportunity to grow the project from the (indie hacker land, backend dev, entrepreneurs, full stack devs, people learning to code) in the enterprise land (to target front end developers, Fortune 500 companies). In order to execute, we need to have outstanding accessibility, bundle size & performance (without to forget the features of course). Today, +50% of the team starts their React design system do it from scratch. People going with the "from scratch approach" have different motives. I believe it's the fear of dependencies. I wish I could dive more in the hidden fear behind it, maybe I will learn more about it. I will keep digging. Starting from scratch shouldn't be the industry standard. It's wasteful. It should only be an option when you have +5 full-time developers team and a year or two ahead of you. People underestimate the time it takes and the number of iterations necessary to get the components right. We have 350k developers continuously giving us feedback on what we do wrong and reacting on it. I believe that Material-UI could be a one-stop components store. We can enable teams to reach a quality of components that they would never be able to reach without Material-UI in the same period of time. To do that, I think that we should prioritize the following aspect of a11y in this order:
What do you think? |
As a long term user of MUI that has promoted it heavily internally at my company to the point where we use it on 100% of our next-gen products used by thousands of fortune-500/governmental customers, i can speak to the immense value proposition that out-of-the-box accessibility support increasingly brings us.
I think this boils down to the fact that accessibility is hard! I strongly believe as developers we should be doing more to cater to users that benefit from accessibility. There is a huge knowledge gap for what is required to make an application accessible. MUI is in a unique position due to its market share to promote and bring awareness to accessibility like you are already doing in your components and in the docs!
I think this is key. There is an ever increasing demand in North America (and I would hope this also extends to Europe/Global) that web sites/applications be accessible. Government and private organizations are increasingly requiring that the applications they procure meet accessibility requirements. For example my company does significant business with the Canadian/US Government that often require by mandate that our products meet WCAG AA specifications or they will close the door on us even if our product is superior to competitors.
💯. The built-in styling that MUI provides is nice, but what I've found even more valuable is the amazing, intuitive, consistent API, including the out-of-the-box accessibility support. We've been able to transform the styling using |
Accessibility in some countries is the law. In the UK you could be in trouble if your service is not accessible: https://www.gov.uk/service-manual/helping-people-to-use-your-service/making-your-service-accessible-an-introduction. For us this makes adopting something like material ui across the company a real challenge. Ignoring it because the majority of users don't care could get you sued. |
@adamscybot Same in the US: #14187. |
I wouldn't even go as far as public facing websites. I don't think we're that far ahead yet. It's more of a problem if companies build internal tools (which we already know some). Companies are required to hire a certain quote of people with disabilities (germany) at a certain size. They can't do that if their internal tools aren't accessible. |
@oliviertassinari @eps1lon sorry to ping, but i didn't want to create a new issue and drive you guys nuts 😛. Do you guys have a plan to address the outstanding a11y issues with Menu/MenuList? Should we open a new issue to track? |
I have it written down for this week. |
@eps1lon @ianschmitz I'll get the rest of my thoughts about this documented within the next couple days as well. The biggest Menu/MenuList issue was taken care of by #16450, but there are one or two minor issues outstanding. |
The actual issue is dispatching
keydown
events to custom targets. It should always be dispatched ondocument.activeElement
because that's how the spec defines it.Close #16294, #15973
@ryancogswell Could you take a look at the new tests?