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

Cannot override defaultProps using variants #7635

Closed
fzaninotto opened this issue May 4, 2022 · 0 comments · Fixed by #7636
Closed

Cannot override defaultProps using variants #7635

fzaninotto opened this issue May 4, 2022 · 0 comments · Fixed by #7636
Assignees
Labels

Comments

@fzaninotto
Copy link
Member

What you were expecting:

Being able to set all inputs as outlined using a MUI theme:

const theme = {
    components: {
        MuiTextField: {
            defaultProps: {
                variant: 'outlined',
            },
        },
    },
};

What happened instead:

The inputs keep the filled variant.

image

Steps to reproduce:

I forked the simple example codesandbox to give it a custom theme:

https://codesandbox.io/s/cranky-bhabha-7xqjwy?file=/src/index.tsx

Forms and filters should use the outlined variant, but they don't

Related code:

In fact, defaultProps from the theme only work if there is no default value in the component code. But all our inputs define their variants and margins.

for instance, in ResettableTextField:

        const {
            clearAlwaysVisible,
            InputProps,
            value,
            resettable,
            disabled,
            variant = 'filled',
            margin = 'dense',
            className,
            ...rest
        } = props;

The default values for variant, margin and size should be defined in the default theme, not in the components.

Other information:

Environment

  • React-admin version: 4.0.2
  • Last version that did not exhibit the issue (if applicable): 3.19
  • React version: 17
  • Browser: Chrome
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.

1 participant