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

TextField "size" prop is not overrideable by theme #9546

Closed
PedroPerpetua opened this issue Dec 26, 2023 · 2 comments · Fixed by #9554
Closed

TextField "size" prop is not overrideable by theme #9546

PedroPerpetua opened this issue Dec 26, 2023 · 2 comments · Fixed by #9554
Labels

Comments

@PedroPerpetua
Copy link

What you were expecting:
A theme override should be able to set the size prop on the TextInputs, given that it's a style prop that doesn't depend on anything else.

What happened instead:

Setting the size prop's default on the theme to "medium" doesn't actually change any inputs; they need to be changed on a one-by-one basis by passing the prop size="medium" to ALL inputs if we want a global override.

Steps to reproduce:

  1. Creat a theme with the following definition:
const theme = {
  components: {
    MuiTextField: {
      defaultProps: {
        size: 'medium',
      },
  },
};
  1. Apply the theme
  2. Create a TextInput somewhere

Related code:

Relevant code:

// ra-ui-materialui/src/input/ResettableTextField lines 155-174
<StyledTextField
    value={value}
    InputProps={{
        classes:
            props.select && variant === 'filled'
                ? { adornedEnd: inputAdornedEnd }
                : {},
        endAdornment: getEndAdornment(),
        ...InputPropsWithoutEndAdornment,
    }}
    disabled={disabled}
    variant={variant}
    margin={margin}
    className={className}
    // HERE
    size="small"
    // ^
    {...rest}
    onFocus={handleFocus}
    onBlur={handleBlur}
    inputRef={ref}
/>

Other information:

This can be easily fixed by removing the prop from here and applying it to RA's default theme as a defaultProp instead; this way, we can override it ourselves if needed.

Environment

  • React-admin version: 4.16.4
@fzaninotto
Copy link
Member

You're right, this should be done at the theme level. But since this is a breaking change, we can only publish this change in a major version. We're preparing the next major in the next branch, would you like to open a PR to fix it?

@fzaninotto
Copy link
Member

Fixed by #9554

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

Successfully merging a pull request may close this issue.

2 participants