-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Select] Fix display when no value is selected #16294
Conversation
Details of bundle changes.Comparing: 1052126...95a9fed
|
I spent a fair bit of time trying to address the existing
Other possible issues unrelated to a11y:
Hope this helps move things forward. I tried to fix the code as is, but when digging deeper it seems like i would have to significantly refactor these components and wanted to chat with you guys first. I may require your assistance in these changes as well as they appear to be fairly complex with the nature of our component composition and different requirements for the focus depending on the component. |
Just some quick thoughts without going through all the resources. But I will prioritize this for the rest of the week (research, impl and test). We should get this right at some point. @ryancogswell did most of the work regarding focus logic in the menu. He should have a better overview over outstanding issues. In regards to test it would be sufficient for now to write a fixture and place it in ./pages. This can be used for manual testing until we figure out how to proceed with the current test setup. There's currently no robust solution to test this behavior automatically.
Don't bother about it for now. If there is an actual performance issue we should profile it and address it in another PR. As of right now a render call isn't a bottleneck for us.
I guess this may be used to forward to focus to the first item in the list. I don't think you focus the whole menu. But I might be missing something. |
Thank you very much. Let me know if I can help in any way. I'd be happy to help validate any solutions from a user point of view as well! This has been an unfortunate blocker to upgrade to v4 for us due to our accessibility requirements in our products. I appreciate your team's focus on accessibility as it's one of the few component libraries that take it seriously.
Agreed it's not an issue for this PR. Seemed fishy so i thought i'd point it out. May be a performance issue for some applications that have many
I believe you're correct yes, sorry for the confusion. I guess i was thinking more from a API point of view, we have |
I'll try to take some time within the next few days to respond to @ianschmitz's points above as far as the reasoning behind the changes and links to the discussions related to the changes. I definitely think it is worth more discussion before embarking on a significant rewrite of the focus logic. |
@ianschmitz Rather than try to respond to all your points more comprehensively (which would significantly delay receiving my feedback), I'm going to respond to them one-by-one. Then I can at least quickly provide info on some of the more straightforward questions.
This functionality existed in v3, but was handled via |
@ianschmitz Correct, we had a regression somewhere, the baseline is #5186 (comment):
|
The color fix seems simple: diff --git a/packages/material-ui/src/ListItem/ListItem.js b/packages/material-ui/src/ListItem/ListItem.js
index 054ecfc05..2e41fd85a 100644
--- a/packages/material-ui/src/ListItem/ListItem.js
+++ b/packages/material-ui/src/ListItem/ListItem.js
@@ -23,7 +23,7 @@ export const styles = theme => ({
paddingTop: 8,
paddingBottom: 8,
'&$focusVisible': {
- backgroundColor: theme.palette.action.selected,
+ backgroundColor: theme.palette.action.hover,
},
'&$selected, &$selected:hover': {
backgroundColor: theme.palette.action.selected, |
From what I can tell looking at the implementation #15973 is caused by a combination of:
|
Should we already merge these changes? I believe they are already a good first step. |
I'd like to wait till the next release. I don't understand why/how this fix works and like to explore the other two possibilities raised above. |
Alright I got a bit side-tracked by the Menu issue but I think I understand this particular issue now. I suspect that the current implementation is based on the tests. For example we check if there is an element focused in the keydown handler. But a keydown event will never hit the list unless the list or some child was focused:
-- https://www.w3.org/TR/uievents/#events-keyboard-event-order So the target of the keydown will be the body, root element or the focused element. If it's the body or root element the keydown will not be triggered in the list. Ergo a keydown on the list will always have an activeElement. Which brings us to the So as far as I can tell the fix is "just" - !list.contains(currentFocus)
+ list === currentFocus This causes a bunch of tests in MenuList integration tests to fail. I'll try the same approach as with the forwardRef implementation: Rewrite the tests (this time with react-testing-library). Then check if they either already fail, or pass with the new implementation and just require a new test. Hope that makes sense. |
@eps1lon I agree. Whenever I looked at that code in the past, I wrongly assumed that Along with this change a test should be added for arrow keys where focus is on the list and disableListWrap=true. |
I'm reopening to solve the no value selected height issue. |
ce150c4
to
107ffb5
Compare
107ffb5
to
25af118
Compare
25af118
to
7521d88
Compare
@@ -287,15 +287,15 @@ describe('<SelectInput />', () => { | |||
describe('prop: autoWidth', () => { | |||
it('should take the anchor width into account', () => { | |||
const wrapper = mount(<SelectInput {...defaultProps} />); | |||
const selectDisplay = wrapper.find('[data-mui-test="SelectDisplay"]').instance(); | |||
const selectDisplay = wrapper.find('[role="button"]').instance(); |
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.
👍
a81a495
to
3f0759e
Compare
3f0759e
to
95a9fed
Compare
Fixes #15973.Outstanding issues to be fixed:- [ ] Selected menu item background color? See https://material-components.github.io/material-components-web-catalog/#/component/select and notice the use of the primary color on the selected item. Keyboard user can't differentiate the selected item (item equal to thevalue
of the select) vs the item they have highlighted with their keyboard