[Select] Fix endAdornment overlapping the open indicator#48723
[Select] Fix endAdornment overlapping the open indicator#48723siriwatknp wants to merge 8 commits into
Conversation
Deploy previewhttps://deploy-preview-48723--material-ui.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
4ba2352 to
3cc7626
Compare
3cc7626 to
e3162eb
Compare
Position a present endAdornment absolutely so the select fills the full width and its chevron stays clickable; reserve the space via the --_endAdornmentWidth variable. Covers Select and NativeSelect. Add Select/NativeSelect endAdornment to the input-adornments demo and a SelectEndAdornment regression fixture.
e3162eb to
ac95601
Compare
| // use CSS variable to keep specificity | ||
| '--_trailingPad': '14px', | ||
| paddingRight: 'var(--_trailingPad)', | ||
| [`&.${selectClasses.root}`]: { | ||
| '--_trailingPad': '0px', | ||
| }, |
| // The endAdornment sits left of the chevron (not over it) and the value clears | ||
| // both, across variants and with a start adornment present. |
There was a problem hiding this comment.
The fixture could follow the SelectOverflow fixture have a long value + small fixed width to test any clipping/overlap on the right side
Let me try another approach, what I did was making end adornment on Select absolute to remove the padding on the InputBase-root (Select-root) because the padding prevent clicking the edge from opening the popup. I am trying another approach to make clicking on the Select-root to also opens the popup, if it works well the CSS for adornment will be simpler and consistent with TextField. |
To make them consistent, clicking the Select root must also open the select popup, I tried but it's very fragile does not work well with native select. This makes me realize why this issue is not fixed a long time ago because the behavior differences force the CSS implementation to be different. I think it's better to fix the CSS (the initial approach I took) instead. Meaning, the end adornment of TextField (input) and Select will have different position. On Select, it's absolute so that the select can be fullwidth. |





closes #45270
This PR is safe, no CSS specificity change due to CSS variable hoisting.
Before: https://stackblitz.com/edit/react-v5frgvqx?file=Demo.tsx

After:

Problem
Selectand<TextField select>don't work well with an end adornment. The adornment is laid out on top of the dropdown chevron and shrinks the trigger, so clicking the open/close indicator (or the area under the adornment) doesn't open the menu.Fix
endAdornmentout of the flex flow so the select fills the full width and the whole field opens the menu.Select, so the trailing space is owned in one place and stays consistent across variants.Only selects that actually have an
endAdornmentare affected; other inputs are unchanged.Out of scope
Clicking on the adornment does not open the popup.
Demo & test
Select(with anendAdornment) andNativeSelect(with astartAdornment) to the Input Adornments demo across the outlined, filled, and standard variants.