Skip to content

fix(password): Add inline confirm password validation#3275

Merged
vbudhram merged 1 commit intomasterfrom
issue-631
Nov 14, 2019
Merged

fix(password): Add inline confirm password validation#3275
vbudhram merged 1 commit intomasterfrom
issue-631

Conversation

@vbudhram
Copy link
Copy Markdown
Contributor

@vbudhram vbudhram commented Nov 7, 2019

Fixes #631

inline_password

@vbudhram vbudhram self-assigned this Nov 7, 2019
events: assign({}, FormView.prototype.events, {
'click .use-different': preventDefaultThen('useDifferentAccount'),
'keyup #vpassword': '_onConfirmPasswordKeyUp',
'blur #vpassword': '_onConfirmPasswordBlur',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added check on blur because if user tabs to age input and the delay hasn't check it, it will automatically show the tooltip error. It seemed to be a little smoother.

const t = msg => msg;

const PASSWORD_INPUT_SELECTOR = '#vpassword';
const DELAY_BEFORE_PASSWORD_CHECK_MS = 2000;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanfeeley 2 seconds seem reasonable to me while manually testing. Any objections?

@shane-tomlinson shane-tomlinson self-requested a review November 8, 2019 15:24
@vbudhram vbudhram force-pushed the issue-631 branch 2 times, most recently from 60467d1 to 9bd8aca Compare November 8, 2019 16:17
@vbudhram
Copy link
Copy Markdown
Contributor Author

vbudhram commented Nov 8, 2019

@mozilla/fxa-devs I think this is ready! r?

@vbudhram vbudhram requested a review from a team November 8, 2019 16:39
Comment on lines +124 to +129
_onConfirmPasswordKeyUp() {
this.checkPasswordsMatchDebounce();
},

_onConfirmPasswordBlur() {
this._checkPasswordsMatch();
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the check is performed twice when I tab out of the confirm password field? Once on the blur, and then again DELAY_BEFORE_PASSWORD_CHECK_MS after the last debounce call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yea, it does. Let me add a few checks to make this work a little smoother.

@vbudhram
Copy link
Copy Markdown
Contributor Author

@chenba made the updates!

@vbudhram
Copy link
Copy Markdown
Contributor Author

@davismtl is this something you would like to get on train 150?


_onConfirmPasswordKeyUp() {
if (!passwordCheckLock) {
passwordCheckLock = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the previous debounce behavior. IIRC previously debounce is called on every keyup. With this extra state, debounce is called on the first keyup, then again on the first keyup after DELAY_BEFORE_PASSWORD_CHECK_MS. If the blur handler executes during the delay, it won't perform the check since passwordCheckLock will be true.

Is this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea this was intentional because otherwise you would see a slight flicker on the tooltip when called twice.

@vbudhram vbudhram force-pushed the issue-631 branch 2 times, most recently from 19e16cf to 479c7e5 Compare November 14, 2019 17:15
@vbudhram
Copy link
Copy Markdown
Contributor Author

So on further investigating and testing, I am opting to remove the password match check on blur. This means that when a user tabs over to the age field, it will rely on the debounced password check rather than performing the check automatically.

In practice it works wells and I don't see a huge difference. The second password field will get focused as part of the debounced function.

Keeping the original behavior did not play well with the first password field (you couldn't focus the input to change it). I think we can come up with a more general solution that will work for both password fields as part of the work @LZoog is doing.

cc @davismtl @mozilla/fxa-devs r?

@vbudhram vbudhram requested review from a team and chenba November 14, 2019 17:25
Copy link
Copy Markdown
Contributor

@chenba chenba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@vbudhram vbudhram merged commit e098929 into master Nov 14, 2019
@vbudhram vbudhram deleted the issue-631 branch November 20, 2019 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate password & vpassword inline instead of on form submit

2 participants