-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
[Autocomplete] for Voiceover on Mac is reading incorrect labels on any browser #24198
Comments
@inform880 I can reproduce it too, since the first version. Wow, I can't believe it wasn't reported before. How is the component even usable with this behavior? 🙈 From what I understand, the bug has been here for 1 year and unnoticed… It looks like VoiceOver caches the results per DOM node. What do you think about the following fix? diff --git a/packages/material-ui/src/useAutocomplete/useAutocomplete.js b/packages/material-ui/src/useAutocomplete/useAutocomplete.js
index a47295e97d..4510f826a4 100644
--- a/packages/material-ui/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui/src/useAutocomplete/useAutocomplete.js
@@ -1005,7 +1005,7 @@ export default function useAutocomplete(props) {
const disabled = getOptionDisabled ? getOptionDisabled(option) : false;
return {
- key: index,
+ key: `${getOptionLabel(option)}-${index}`,
tabIndex: -1,
role: 'option',
id: `${id}-option-${index}`, Do you want to work on a pull request? :) |
Don't we want to remove the index entirely from the key in case these are re-ordered? |
@eps1lon From what I understand, having the |
Why would we do that? It's a mistake. |
@eps1lon It allows the component to be more versatile. From what I understand it doesn't matter if DOM nodes aren't shared as much as they could have been, at least, we can benchmark the difference once somebody takes on this effort. My assumption is that it's negligible, not worse taking into account. I think that the best-case scenario would be for us to have a value we can leverage, in which case I think that we can assume uniqueness, maybe it will come with #23708. It's how Downshift solves the problem. Alternatively, we can try to be greedy. We can try to create a new constrain by asking for the label to be unique. Then we can wait and see if it "fly". I have no idea if it will. diff --git a/packages/material-ui/src/useAutocomplete/useAutocomplete.js b/packages/material-ui/src/useAutocomplete/useAutocomplete.js
index a47295e97d..4510f826a4 100644
--- a/packages/material-ui/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui/src/useAutocomplete/useAutocomplete.js
@@ -1005,7 +1005,7 @@ export default function useAutocomplete(props) {
const disabled = getOptionDisabled ? getOptionDisabled(option) : false;
return {
- key: index,
+ key: getOptionLabel(option),
tabIndex: -1,
role: 'option',
id: `${id}-option-${index}`, |
I have a PR up with the most recent suggested fix, and it seems to work. This is my first time contributing to such a big project, any feedback is appreciated. |
What does this mean?
Why would you render option with the same label? How would end-users be able to decide which option to choose from? |
@eps1lon It means that, right now, having unique labels isn't a constraint the Autocomplete enforces. The component works (technically, I'm not judging the UX) with duplicates. It's possible that some applications have options with identical labels.
Developers can customize how each option is rendered. The notion of "label" was introduced to render a value inside the textbox but it can be bypassed.
I agree, adding this new constraint has the potential to yield a better UX. It's why I called this approach "greedy", which doesn't have a negative connotation, on the contrary, we can try it out, learn, see if we get pushback from developers. Hopefully, it will fly. |
Why not?
There are infitenitely many possible applications so anything is possible. That isn't an argument for anything.
Should it be bypassed?
A "greedy" approach is one that yields a better UX? Why do you add this qualifier to your statement when that is literally the whole point of a component library. Why would you use a component library that does not yield a better UX? |
I think that these two concerns (DX and UX) can be discussed on their own even if interdependent. Improving the two can sometimes be at odds, tradeoffs need to be made.
In the nominal use case, it seems that we both agree that the answer is no.
The meaning for the adjective I had in mind is "always wanting more". I think that it's healthy for an API to try to impose as many constraints as it can possibly get away with. The more useful constraints an API has, the more valuable properties it can yield in exchange.
The primary motivation for using a component library is a. saving developers time b. filling the gap of missing design skills (UI & UX) among developers. At least, it's what I think we can conclude from our experience so far. I think that having a pit-of-success for the API to yield a better UX is inside value proposition b. |
Current Behavior 😯
Voiceover for Mac is reading the values incorrectly on the component, after typing characters and triggering the filter. It seems to always read off the same values for after you type in more than one character. After typing in two ore more characters, it sticks with the read labels from typing in one character.
Expected Behavior 🤔
The values should be read correctly, even after typing in multiple characters.
Steps to Reproduce 🕹
Steps:
Context 🔦
I am trying to accomplish a completely a11y website for a client.
Your Environment 🌎
`npx @material-ui/envinfo`
The text was updated successfully, but these errors were encountered: