-
-
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
[material-ui][Autocomplete] Shouldn't resize when hovering #42452
Merged
ZeeshanTamboli
merged 5 commits into
mui:next
from
ZeeshanTamboli:fix-issue-42340-autocomplete-hover
Jun 5, 2024
Merged
[material-ui][Autocomplete] Shouldn't resize when hovering #42452
ZeeshanTamboli
merged 5 commits into
mui:next
from
ZeeshanTamboli:fix-issue-42340-autocomplete-hover
Jun 5, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZeeshanTamboli
added
package: material-ui
Specific to @mui/material
component: autocomplete
This is the name of the generic UI component, not the React module!
regression
A bug, but worse
needs cherry-pick
The PR should be cherry-picked to master after merge
labels
May 30, 2024
Netlify deploy previewhttps://deploy-preview-42452--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
This reverts commit 7a5ff87.
DiegoAndai
approved these changes
Jun 4, 2024
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 the detailed explanation @ZeeshanTamboli 🚀
Hi @ZeeshanTamboli , can you please provide me an explanation of how to solve this in an existing project? |
joserodolfofreitas
pushed a commit
to joserodolfofreitas/material-ui
that referenced
this pull request
Jul 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component: autocomplete
This is the name of the generic UI component, not the React module!
needs cherry-pick
The PR should be cherry-picked to master after merge
package: material-ui
Specific to @mui/material
regression
A bug, but worse
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #42340
Regression from #41781
In #41781, to prevent the clear icon from overlapping with text in the autocomplete and to add spacing when hovered,
min-width: 0
was applied as per this explanation.When zero minimum width on hover was applied:
Before.fix.issue.42340.mp4
However, this caused an issue (#42340) where hovering over the autocomplete shrinks its width (setting min width to
0
) because the minimum width is set to 30px.Removing the zero minimum width on hover fixes this issue. The original fix (#41781) addressed a specific edge case for small autocompletes (see the
width
in regression test).When the zero minimum width is removed on hover, as seen in the following video, the input text and clear icons are close but still acceptable:
After.fix.issue.42340.mp4
IMO, developers should ensure the autocomplete is rendered in a sufficient space where the text and clear icon don't overlap.
The main fix in #41781 was to prevent wrapping of flex items, which is needed only when
multiple
options are supported in the autocomplete. This retains the fix without needing minimum width on hover.Before: https://codesandbox.io/p/sandbox/icy-voice-mh8ff2-forked-hxh565?file=%2Fsrc%2FDemo.tsx%3A12%2C28
After: https://codesandbox.io/p/sandbox/icy-voice-mh8ff2-forked-fkrfrt?file=%2Fsrc%2FDemo.tsx
Second commit replaces the deprecated
InputProps
withslotProps.input
.