Skip to content

MUI anyOf select title gets cropped if longer than options #4484

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
3 of 4 tasks
TheOneTheOnlyJJ opened this issue Feb 5, 2025 · 2 comments
Open
3 of 4 tasks

MUI anyOf select title gets cropped if longer than options #4484

TheOneTheOnlyJJ opened this issue Feb 5, 2025 · 2 comments

Comments

@TheOneTheOnlyJJ
Copy link

TheOneTheOnlyJJ commented Feb 5, 2025

Prerequisites

What theme are you using?

mui

Version

5.22.4

Current Behavior

This:

Image

Notice how for the options Option A, Option B, and Option C, the Choose Option text gets cropped and has ... added to it.
This is because the select widget length is calculated based on the options' lengths and does not account for the length of the title.

Expected Behavior

Ideally, the width of the select widget should be calculated like this: max(titleWidth, max(optionsWidths)).
Could such a small fix be made? Maybe a CSS property exists for this?
If Material UI does not allow such title length calculation, I will also open an issue there.

Steps To Reproduce

A simple anyOf schema with subschemas having titles shorter than the select title.

@TheOneTheOnlyJJ TheOneTheOnlyJJ added bug needs triage Initial label given, to be assigned correct labels and assigned labels Feb 5, 2025
@TheOneTheOnlyJJ TheOneTheOnlyJJ changed the title MUI any of select title gets cropped if longer than options MUI anyOf select title gets cropped if longer than options Feb 5, 2025
@heath-freenome
Copy link
Member

@TheOneTheOnlyJJ I've faced this problem myself and built an extension of the TextField to add the title to the label when it is cropped. Right now we don't have an easy way of targeting the one-of component, but it would be pretty easy for us to add one. Then you could apply a targeted CSS solution for this. I also would suggest writing an issue with MUI to see if they can help you provide a fix

@TheOneTheOnlyJJ
Copy link
Author

@TheOneTheOnlyJJ I've faced this problem myself and built an extension of the TextField to add the title to the label when it is cropped. Right now we don't have an easy way of targeting the one-of component, but it would be pretty easy for us to add one. Then you could apply a targeted CSS solution for this. I also would suggest writing an issue with MUI to see if they can help you provide a fix

As you suggested, I've opened mui/material-ui#45276.
Once a solution gets found there, I believe we can simply copy & paste it in RJSF's MUI anyOf and oneOf code. I say this because I expect the solution to be some CSS styling formula applied to the widget. Such a solution is a lot more likely than a new prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants