Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Make password creation form functional #102

Merged
merged 4 commits into from
Jan 18, 2022

Conversation

voltrevo
Copy link
Collaborator

@voltrevo voltrevo commented Jan 14, 2022

Dependent PR

This PR builds on top of #95. Please review and merge that one first.

What is this PR doing?

Adds functionality to the password creation form:

  • Displays password strength using method from previous work
    • Shows weak/strong/etc
    • Description elaborating on weak/strong/etc
    • Horizontal bar with a width corresponding to granular strength measurement
  • Confirm password box shows whether it is correct/incorrect/incomplete
  • Continue button is disabled if a password hasn't been entered or the confirm field doesn't match

I included some naive css this time because I couldn't help it. Just things like background-color: green though. Intended to be thrown away.

Screen Shot 2022-01-14 at 3 59 08 pm

How can these changes be manually tested?

Visit the password creation form and verify the above.

Does this PR resolve or contribute to any issues?

Resolves #97, resolves #98.

Checklist

  • I have manually tested these changes
  • Post a link to the PR in the group chat

Guidelines

  • If your PR is not ready, mark it as a draft
  • The resolve conversation button is for reviewers, not authors
    • (But add a 'done' comment or similar)

@github-actions github-actions bot added the extension Browser extension related label Jan 14, 2022
Comment on lines +47 to +57
const confirmFieldClasses = ['password-confirm-field'];

if (confirmPasswordFieldValue === '') {
confirmFieldClasses.push('empty');
} else if (confirmPasswordFieldValue === passwordFieldValue) {
confirmFieldClasses.push('correct');
} else if (passwordFieldValue.startsWith(confirmPasswordFieldValue)) {
confirmFieldClasses.push('incomplete');
} else {
confirmFieldClasses.push('incorrect');
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

To prevent redundant computation in render cycles and prevent subcomponents from unnecessarily re-rendering, generating values like this can be memoized. https://reactjs.org/docs/hooks-reference.html#usememo

Suggested change
const confirmFieldClasses = ['password-confirm-field'];
if (confirmPasswordFieldValue === '') {
confirmFieldClasses.push('empty');
} else if (confirmPasswordFieldValue === passwordFieldValue) {
confirmFieldClasses.push('correct');
} else if (passwordFieldValue.startsWith(confirmPasswordFieldValue)) {
confirmFieldClasses.push('incomplete');
} else {
confirmFieldClasses.push('incorrect');
}
const confirmFieldClasses = React.useMemo(() => {
const classes = ['password-confirm-field'];
if (confirmPasswordFieldValue === '') {
classes.push('empty');
} else if (confirmPasswordFieldValue === passwordFieldValue) {
classes.push('correct');
} else if (passwordFieldValue.startsWith(confirmPasswordFieldValue)) {
classes.push('incomplete');
} else {
classes.push('incorrect');
}
return classes;
}, [confirmPasswordFieldValue, passwordFieldValue]);

Now confirmFieldClasses will only become a new Array object when either confirmPasswordFieldValue or passwordFieldValue changes.

I don't think this is needed for this round of changes, but something to keep in mind.

@jacque006 jacque006 merged commit 3e3fa8d into bw-90-followup Jan 18, 2022
@jacque006 jacque006 deleted the bw-97-password-creation-form branch January 18, 2022 22:46
@voltrevo voltrevo restored the bw-97-password-creation-form branch January 24, 2022 03:20
@voltrevo
Copy link
Collaborator Author

This was merged before #95. Oops.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extension Browser extension related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants