[material-ui][Autocomplete] Shouldn't resize when hovering#42452
Merged
ZeeshanTamboli merged 5 commits intomui:nextfrom Jun 5, 2024
Merged
[material-ui][Autocomplete] Shouldn't resize when hovering#42452ZeeshanTamboli merged 5 commits intomui:nextfrom
ZeeshanTamboli merged 5 commits intomui:nextfrom
Conversation
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
Member
DiegoAndai
left a comment
There was a problem hiding this comment.
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
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: 0was 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
widthin 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
multipleoptions 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
InputPropswithslotProps.input.