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

Default props support missing #1340

Closed
jasonkylefrank opened this issue Oct 3, 2019 · 1 comment · Fixed by #1796
Closed

Default props support missing #1340

jasonkylefrank opened this issue Oct 3, 2019 · 1 comment · Fixed by #1796
Labels
bug 🐛 Something isn't working good to take Help wanted
Milestone

Comments

@jasonkylefrank
Copy link

jasonkylefrank commented Oct 3, 2019

Environment

Tech Version
@material-ui/pickers 3.2.6
material-ui 4.3.3
React 16
Browser
Peer library date-fns

Question / issue

How can we supply default props to these controls?

One of the reasons we need to do this is that we have a customized MUI TextField component (we create a wrapper component around MUI's TextField) that we need every instance of these pickers to use. This will ensure our theming and behavior customizations on the TextField will be consistent for all TextFields across our app.

So far I have been able to pass-in our custom TextField component via the TextFieldComponent prop. But obviously that's not very DRY to have to do that on every single instance. And we need to set it up so that other developers don't have to remember to pass that in every time.

We accomplish default props with our other MUI controls by using their built-in theming system. They have a props key (on the theme object) that can be utilized to set such default prop values. See this section of their docs.

So far I have tried to accomplish setting some default props for these picker controls by specifying a proper key in the theme object. I can't seem to tell which key to use to affect the component which renders the TextField, so for now I'm just trying several possible MUI Pickers keys (none of which are working):

image

image

Summary

So how do we set default props on these controls?

@oliviertassinari oliviertassinari added the bug 🐛 Something isn't working label Mar 31, 2020
@oliviertassinari oliviertassinari changed the title Question: How to set default props Default props support missing Mar 31, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 31, 2020

@jasonkylefrank Thanks for the report, you are right, we miss the support for default props. We should 1. use withStyles over makeStyles, 2. provide a name to the stylesheets.

For instance: it won't for this public component:
https://github.com/mui-org/material-ui-pickers/blob/0d41c48aaa8b9b6f67e72deee9583340cd218b89/lib/src/views/Calendar/Calendar.tsx#L57

On the TypeScript side of the problem, we will need to implement: mui/material-ui#19427.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working good to take Help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants