Empty password for autocomplete (React.js)

After my account is autocompleted by the browser, the entered password value will be empty. After I go to the password field, the value will become magical, there are also many events triggered by the browser that do not make sense. ( onChange to enter a password is not included.)

  • Why is input[type=password] empty?
  • Why doesn't autocomplete password input onChange event?
    (it fires on normal input)
  • Bonus question: why is there a second (unnecessary) focus / blur event?

1. Both inputs are set to type="text"

  • Both inputs are received once (without autofill)

console1

Note: my inputs are uncontrolled, but with state preservation, and I track state changes when focusing, blurring, changing

  • entered=true when value is entered
  • focused=true when onFocus running, =false when onBlur running
  • peek=true when I need to programmatically force type from password to text

2. The input signal is set to type="password"

(See how the form autocompletes.)

form

console2

  • ...
  • 2.render ( red arrow ) - browser focused input
  • onChange launched by email
  • 3.render - internal state changed ( entered=true )
  • 4.render - the browser has not focused input
  • 5.render ( yellow arrow ) - browser focused input again?
  • 6.render - browser did not focus input
    The browser has not made changes to the dom element

  • preview password - input type changed to text programmatically

  • manual validateForm () - password is empty, the form is invalid
  • Manual interaction also says the value "" empty

Interestingly, after clicking the PrtScr button in the browser, this value becomes available, and the form gets rendered - as when focusing the input manually.

+5
source share

Source: https://habr.com/ru/post/1271771/


All Articles