-
-
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
[material-ui][joy-ui][base-ui][Autocomplete] Keep in sync highlighted index when the option still exists #41306
[material-ui][joy-ui][base-ui][Autocomplete] Keep in sync highlighted index when the option still exists #41306
Conversation
Netlify deploy previewhttps://deploy-preview-41306--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
76d899c
to
920b7e5
Compare
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.
@CGNonofr Are you trying to solve an existing GitHub issue? If not, could you start by creating a new issue and provide a CodeSandbox reproduction?
No, I didn't find any issue related to it I sure can create an issue if you process needs it. Regarding the CodeSandbox reproduction, I've already changed a test (the last commit) that highlight the issue, is that enough? |
A codesandbox reproduction would still help. |
Created the issue and linked it in the PR description (#41386) |
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.
The fix doesn't work as expected. I tested it using this PR's build: "@mui/material": "https://pkg.csb.dev/mui/material-ui/commit/920b7e5f/@mui/material"
. See the CodeSandbox - https://codesandbox.io/p/sandbox/mui-autocomplete-bug-forked-tg875l.
for it to work, we also need to add |
Why is it necessary? The prop is optional. Keyboard navigation works in general (no option insertion) without it being required. What's the rationale behind needing it in this specific case? |
because all the items are changed, the alternative is to reuse the items: https://codesandbox.io/p/sandbox/mui-autocomplete-bug-forked-mxsvf7?file=%2Fsrc%2FApp.js%3A22%2C68 |
How would developers know they need to use that prop? Also, the above CodeSandbox is inaccessible. Perhaps you need to grant permissions to me. |
You're right, the code is not correct, I will come up with something better It still feel weird to me that the option comparison rely exclusively on the label without any way to override that behavior (so it's impossible to rename an option without losing it's highlighting)
my bad, it's now shared |
I didn't understand what you mean. You can use |
e59410a
to
41d7cfa
Compare
@ZeeshanTamboli ok I've rewritten the PR |
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.
Thanks for this fix. The logic and the fix seem solid, but the tests are passing on the master HEAD branch which indicate they're not covering the necessary scenario. Maybe add a new test instead of modifying an existing one. Also, need to update the comment.
Rewritten the PR once again! |
41d7cfa
to
b587c21
Compare
b587c21
to
541c3f6
Compare
… index when the option still exists (mui#41306) Co-authored-by: Loïc Mangeonjean <loic@coderpad.io>
fix #41386
If the highlighted option still exists, it doesn't mean its index in the filtered list didn't change.
The index being out-of-sync with the visually highlighted item create weird behavior when interacting with the keyboard arrows (jumps)
Before: https://codesandbox.io/p/sandbox/mui-autocomplete-bug-94thpd
After: https://codesandbox.io/p/sandbox/mui-autocomplete-bug-forked-87nw9h