Skip to content

[material-ui][Select] Fix autoWidth sizing with InputLabel #45862

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

FGFAnderson
Copy link

@FGFAnderson FGFAnderson commented Apr 9, 2025

Fixes #45276

The implementation of this doesn't quite feel right but the other alternative options I considered had their own problems:

  • The only way to accurately measure the size of a string would be to render it hidden and take the width and set minWidth to that.
  • <InputLabel> doesn't resize the the Select as it's position is absolute, changing this could have consequences of which I don't know
  • To change <InputLabel> to size the Select we would need to get the autoWidth prop from <Select> possibly using <FormControls> useFormControl() hook which seemed like a lot but could be used.

@aarongarciah aarongarciah added component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Apr 10, 2025
@aarongarciah aarongarciah requested a review from siriwatknp April 10, 2025 08:27
@mui-bot
Copy link

mui-bot commented Apr 10, 2025

Netlify deploy preview

https://deploy-preview-45862--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 50bf653

@zannager zannager requested a review from aarongarciah April 30, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Select] Auto Width title get cropped if longer than input value
3 participants