[material-ui][Autocomplete] Current multiple select does not play well with text with ellipsis #40502
Labels
bug 🐛
Something doesn't work
component: autocomplete
This is the name of the generic UI component, not the React module!
duplicate
This issue or pull request already exists
package: material-ui
Specific to @mui/material
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/sweet-platform-5x2k34?file=%2Fsrc%2FApp.js
Steps:
Video attached
Current behavior
The example shows the natural way to code a multiple Autocomplete with text in one line (no wrap) with ellipsis. But this does not play well with the way the internal layout is implemented in the component.
As shown in the video (and can be tested in the linked example) when the component is narrowed to a point where the text should still fit, an additional line (for the input) is appended. (In the example, I've styled the internal input with ligth green). The ellipsis appear too late, and even when it appears, the behavior is not the expected one. One wants that everything fits in one line.
The problem also manifests (perhaps less catastrophically) when we render chips (instead of text).
There seems to be two root causes here.
First and principal: a space a reserved for the input component always (see the light green zone), and a negative margin is placed in the label. This not only plays badly with the nowrap+ellipsis styling, it makes difficult (if not impossible) to get the desired behaviour: display just one line with ellipsis, taking all the available horizontal space. Perhaps the space for the input could be allocated only when the component is focused/active?
Second (less important) : an additional horizontal space is wasted, as assigned to the "clear" button (which is shown only on hover).
This issue is quite related to #20244 , which was closed (wrongly IMO) as duplicate of #19137 )
Expected behavior
No response
Context
No response
Your environment
npx @mui/envinfo
Using Chrome 120, on Windows 11
Autocomplete2024-01-09.174447.mp4
Search keywords: autocomplete ellipsis wrapping
The text was updated successfully, but these errors were encountered: