Skip to content
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] Resizing on hover/focus when displayed in a table with table-layout: auto set #42340

Closed
Martin-Cox opened this issue May 22, 2024 · 7 comments · Fixed by #42452
Assignees
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material regression A bug, but worse

Comments

@Martin-Cox
Copy link

Martin-Cox commented May 22, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/icy-voice-mh8ff2?file=%2Fsrc%2FDemo.tsx

Steps:

  1. Open link
  2. Hover over the Movie autocomplete field

Current behavior

When hovering over the autocomplete field (or when focusing in on it) the autocomplete shrinks. If you position the mouse in the "right" position, the autocomplete will rapidly switch between the full size version and the shrunken version.

MuiAutocompleteShrinking

Expected behavior

The autocomplete field should not resize when hovering over it.

Context

My website allows users to enter data into "editable" tables, where the cells contain MUI fields that the user can enter data into:
image

Your environment

npx @mui/envinfo
  System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 20.11.0 - ~\AppData\Local\Volta\tools\image\node\20.11.0\node.EXE
    npm: 10.3.0 - ~\AppData\Local\Volta\tools\image\npm\10.3.0\bin\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
    Edge: Chromium (125.0.2535.51)
  npmPackages:
    @emotion/react: ^11.11.3 => 11.11.4
    @emotion/styled: ^11.11.0 => 11.11.5
    @mui/base:  5.0.0-beta.40
    @mui/core-downloads-tracker:  5.15.16
    @mui/lab: ^5.0.0-alpha.159 => 5.0.0-alpha.170
    @mui/material: ^5.15.3 => 5.15.16
    @mui/private-theming:  5.15.14
    @mui/styled-engine:  5.15.14
    @mui/system:  5.15.15
    @mui/types:  7.2.14
    @mui/utils:  5.15.14
    @mui/x-date-pickers: ^7.0.0-alpha.9 => 7.3.2
    @types/react: 18.3.1 => 18.3.1
    react: ^18.2.0 => 18.3.1
    react-dom: ^18.2.0 => 18.3.1
    typescript: ^5.3.3 => 5.4.5

I'm using Chrome Version 125.0.6422.60 (Official Build) (64-bit), but this also happens in Firefox 126.0 (64-bit),
My site is using @mui/material 5.15.3, but as demonstrated in the CodeSandbox recreation it is also happening in the latest version of MUI.

I think this is a result of this commit https://github.com/mui/material-ui/pull/41781/files. If I disable the following style on the element it stops resizing:
image

Search keywords: autocomplete

@Martin-Cox Martin-Cox added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 22, 2024
@zannager zannager added the component: autocomplete This is the name of the generic UI component, not the React module! label May 23, 2024
@danilo-leal danilo-leal changed the title Autocomplete resizes on hover/focus when displayed in a table with table-layout: auto set [material-ui][Autocomplete] Resizing on hover/focus when displayed in a table with table-layout: auto set May 28, 2024
@danilo-leal danilo-leal added the package: material-ui Specific to @mui/material label May 28, 2024
@DalSoft
Copy link

DalSoft commented May 28, 2024

Until there is a fix you can workaround with this:

sx={{ "& :hover .MuiAutocomplete-input": { minWidth: "30px" } }}

@Martin-Cox
Copy link
Author

sx={{ "& :hover .MuiAutocomplete-input": { minWidth: "30px" } }}

True, that works for hovering over the input box in this specific scenario, however if you hover over the dropdown element or if you select an item then the Autocomplete will start resizing again.

@DalSoft
Copy link

DalSoft commented May 29, 2024

Yeah that's annoying I think workaround is going to be awkward because of specificity. I'm also looking for a fix or workaround to this issue. This bug means you can't use autocomplete in flexbox without setting a width.

@DalSoft
Copy link

DalSoft commented May 29, 2024

Yeah that's annoying I think workaround is going to be awkward because of specificity. I'm also looking for a fix or workaround to this issue. This bug means you can't use autocomplete in flexbox without setting a width.

Actually looking at the code my workaround is just missing the focused selector.

sx={{ "& :hover .MuiAutocomplete-input, & .Mui-focused .MuiAutocomplete-input": { minWidth: "30px" } }}

@ZeeshanTamboli ZeeshanTamboli added regression A bug, but worse and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 30, 2024
@ZeeshanTamboli
Copy link
Member

It's a regression from #41781. Created PR to fix it: #42452

@mimccio
Copy link

mimccio commented Sep 6, 2024

I'm still having the same issue

resizeonhover.mp4

Thanks for the workaround

@ZoranRavic
Copy link

@mimccio Which version are you on?

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! package: material-ui Specific to @mui/material regression A bug, but worse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants