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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Select] Arrow / caret doesn't scale with theme typography changes #26401

Closed
2 tasks done
sarahannnicholson opened this issue May 20, 2021 · 1 comment 路 Fixed by #26570
Closed
2 tasks done

[Select] Arrow / caret doesn't scale with theme typography changes #26401

sarahannnicholson opened this issue May 20, 2021 · 1 comment 路 Fixed by #26570
Labels
bug 馃悰 Something doesn't work component: select This is the name of the generic UI component, not the React module!

Comments

@sarahannnicholson
Copy link
Contributor

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 馃槸

Using a Select component with custom theme typography causes arrow / caret to not be vertically centered.
image

Expected Behavior 馃

Making changes to the theme's typography should cause components to render proper styles by default. A user of material UI shouldn't need to modify components out of the box when adjusting the theme.
image

Steps to Reproduce 馃暪

https://codesandbox.io/s/busy-feather-uoo3t

Steps:

  1. Use theme provider and adjust font size (eg: 18 instead of default theme 14)
  2. Add provider to app with your theme adjustment for font size
  3. In a child component, use the Select component
  4. Notice how the caret for the Select component is not aligned

Context 馃敠

Looking into the MUI code, this line appears to be hardcoded to calc(50% - 12px)
https://github.com/mui-org/material-ui/blob/e526be50c6f80d8044470fdefa65da7d2e0561d2/packages/material-ui/src/NativeSelect/NativeSelectInput.js#L91

image
To center this absolute item, I the formula is: calc( 50% - [half the caret height]). Since the height: 1em which is proportional to fontSize, a potential fix would be: calc(50% - .5em)

Your Environment 馃寧

`npx @material-ui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @material-ui/envinfo` goes here.
@sarahannnicholson sarahannnicholson added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 20, 2021
@mnajdova mnajdova added component: select This is the name of the generic UI component, not the React module! new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 21, 2021
@siriwatknp
Copy link
Member

@sarahannnicholson would you like to create a PR, your solution looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work component: select This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants