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

Password peek-a-boo #314

Open
raae opened this issue Jun 4, 2021 · 3 comments
Open

Password peek-a-boo #314

raae opened this issue Jun 4, 2021 · 3 comments
Assignees
Labels
- Product enhancement Bettering of exciting functionality

Comments

@raae
Copy link
Owner

raae commented Jun 4, 2021

Add an eye icon to password fields so that the user can view the password they have entered.

Check out example here: https://material-ui.com/components/text-fields/#input-adornments

@raae raae self-assigned this Jun 4, 2021
@raae
Copy link
Owner Author

raae commented Jun 4, 2021

Proposed steps @olavea:

  1. Do this for the current password field in edit password
  2. Create a password field component with this functionality
  3. Use the new password field component everywhere there is a password field

@raae raae added - Product enhancement Bettering of exciting functionality labels Jun 4, 2021
@raae raae assigned olavea and unassigned raae Jun 4, 2021
@olavea
Copy link
Collaborator

olavea commented Jun 9, 2021

The thing is not showing up, but I don't think the warning below solves it. I will keep working.

Warning: React does not recognize the endAdornment prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase endadornment instead.

@olavea
Copy link
Collaborator

olavea commented Mar 10, 2022

an ordinary terniary?

                  {values.showPassword ? <VisibilityOff /> : <Visibility />}

Q
From where comes values.showPassword ?

A

  const [values, setValues] = React.useState({
    ....
    showPassword: false,
  });

Q
From where comes : ?

A

import Visibility from "@mui/icons-material/Visibility"
import VisibilityOff from "@mui/icons-material/VisibilityOff"

Over is printed out
under is NOT printed out

Q
an ordinary icon button, kinda?

                <IconButton
                  aria-label="toggle password visibility"
                  onClick={handleClickShowPassword}
                  edge="end"
                >
                  {values.showPassword ? <VisibilityOff /> : <Visibility />}
                </IconButton>

A

Q
an ordinary onClick handler, kinda?

                <IconButton
                  ....
                  onClick={handleClickShowPassword}
                  ....
                >
                  //  {values.showPassword ? <VisibilityOff /> : <Visibility />}
                </IconButton>

A
Yes and it only sets the value of showPassword to be true and NOT false
showPassword to be true

  const [values, setValues] = React.useState({
    ....,
    showPassword: false,
  });

after spreading in the values ...values,

        </FormControl>
        <FormControl sx={{ m: 1, width: '25ch' }} variant="outlined">
          <InputLabel htmlFor="outlined-adornment-password">Password</InputLabel>
          <OutlinedInput
            id="outlined-adornment-password"
            type={values.showPassword ? 'text' : 'password'}
            value={values.password}
            onChange={handleChange('password')}
            endAdornment={
              <InputAdornment position="end">
                <IconButton
                  aria-label="toggle password visibility"
                  onClick={handleClickShowPassword}
                  onMouseDown={handleMouseDownPassword}
                  edge="end"
                >
                  {values.showPassword ? <VisibilityOff /> : <Visibility />}
                </IconButton>
              </InputAdornment>
            }
            label="Password"
          />
        </FormControl>

import

import InputAdornment from "@mui/material/InputAdornment"
import IconButton from "@mui/material/IconButton"
import Visibility from "@mui/icons-material/Visibility"
import VisibilityOff from "@mui/icons-material/VisibilityOff"

values?

endAdornment={
              <InputAdornment position="end">
                <IconButton
                  aria-label="toggle password visibility"
                  onClick={handleClickShowPassword}

                  edge="end"
                >
                  {values.showPassword ? <VisibilityOff /> : <Visibility />}
                </IconButton>
              </InputAdornment>
            }
            

get userbase up and running

Wait with:

  const handleMouseDownPassword = (event) => {
    event.preventDefault();
  };

....
          <OutlinedInput
....
            value={values.password}
            onChange={handleChange('password')}
            
....
                  onMouseDown={handleMouseDownPassword}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Product enhancement Bettering of exciting functionality
Projects
None yet
Development

No branches or pull requests

2 participants