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] Add eye to password type #6693
Comments
Can use this in the meantime |
Are there any official solutions to this problem of 1.0.0-beta.2? |
@DragonEmperorG You can use composable field https://material-ui-1dab0.firebaseapp.com/component-demos/text-fields#components and add icon into your layout |
I'm starting to work on a material-ui@1.0.0 port of our component right now and I'll send a PR as soon as it's ready. This really should be included in material-ui itself. 😎 |
@oliviertassinari If I add this to the Should this become a separate component instead? |
@leMaik I prefer this option over the state one, but I guess the best would be to have both options. |
🎉 |
@oliviertassinari I'd go with Edit: Right now, I don't see a way to inject any component into an |
Some more thoughts. Maybe we can support both controled and uncontroled behavior. I'm not sure we should introduce two new components. I'm fine with having people building the PasswordField from lower level components. We have 4 options for our
I like option 2. What do you think? |
A password field is something that is so basic that users shouldn't be required to build it themselves. That would just end up in me building a new material-ui-password-field and using that everywhere. 😄 Regarding the options:
I don't want to over-engineer this. After all, it's just a button beside a text field. 😉 Edit: I would say that controlled behavior for password toggling isn't required at all. |
Let's start without it then.
They will have the documentation demo, everybody is copy-pasting the docs demo. I don't know what's the best pattern but I want to avoid duplication and maximize flexibility.
<PasswordInput>
<Input />
</PasswordInput>
<PasswordInput>
{(props) => <Input {...props} />}
</PasswordInput> |
I'll give it a try later this week / next week. Now that I see the approaches (I knew what a HOC is, I just wondered why it would be useful here), I strongly prefer the second one, but again: Why should a user need more than one component to get something as basic as a password field? I want a usage like this to get a toggle-able password field: <PasswordField /> Just because the code can be copy-pasted from the docs doesn't mean that it shouldn't be as simple to use as possible. 😄 |
@leMaik I think that both 2 and 3 are potentially good candidates. Picking one over the other depends on the use cases we want to support, your call.
We have broken the TextField into multiples components in order to support multiples use cases. input with/without label, with/without helper message, and later maybe with a selectfield, datepicker, timepicker.
If that's something you can do without touching lower-level components, that something I would personally label as a success and want to see more :). |
I'll try to come up with a way to extend Maybe I'm just still too much in the 0.x just-configure-it-by-setting-all-the-props mood... |
@leMaik Yeah, we have definitely made a strategic switch.
We are 80% into 1. and 20% into 2. If you find an elegant way to expose the password feature into the |
@leMaik Thanks for the discussion! |
I was thinking about adding the toggle state-functionality directly to the @oliviertassinari Thank you, always happy to have some exchange on how to do things in React. |
@leMaik This means bloating the TextField with some extra code that users might not need. Yeah, I can't see better alternatives, that's where the TextField tradeoff reach his limitations. Sounds good to me as long as users can also escape the TextField abstraction if they need fine grain tunning. |
Hence the |
In line with the compostability of fields have you considered having an So a PasswordField would be <FormControl className={classes.formControl}>
<InputLabel htmlFor="name-helper">Name</InputLabel>
<InputAction>
<IconButton onClick={this.toggleShowPassword}>
{this.state.showPassword?<Hide />:<Eye />}
</IconButton>
</InputAction>
<Input id="name-helper" value={this.state.name} onChange={this.handleChange} />
<FormHelperText>Some important helper text</FormHelperText>
</FormControl> This could then be reused for dropdowns etc.. |
@eyn The Both seem to be using the following pattern: <div className={...}>
<TextField />
<InputAction className={...} />
</div> |
Description
The password field in android contains an eye icon that when clicked shows the password (until released)
Thought it should have been implemented in the material ui too.
Images & references
https://medium.com/@moyinoluwa/password-visibility-toggle-android-support-library-revision-24-2-0-98b422087e5a
Versions
The text was updated successfully, but these errors were encountered: