-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix(fxa-settings): Disable double-clicking on buttons in account recovery key flow #15429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are going to want a similar check when deleting a recovery key. I just tried in production clicking "remove" as many times as I could, and I got like 6 emails telling me I'd deleted my key. 😅 Apparently that's been an existing issue and your fix here does resolve the issue described so it's fine to do in a follow up if you'd prefer but if you've got time it'd be nice to sneak it in here since it's all related.
Yessssss good catch! I just pushed up a fix for this modal too. |
Did you try this locally? I just did and I'm able to click it at least twice 😩 I logged |
Re-tested with a slowed connection and did indeed see requests go through more than once. I've pushed a revised loading state that disables the button as long as the submit function as a whole is in progress. |
8ac4476
to
5d85e6b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+wc😎 Fixes the issue in the ticket. (It's fine with me if you want to scoot the modal issue out elsewhere if you aren't sure about my question.)
@@ -84,6 +85,7 @@ export const FlowRecoveryKeyHint = ({ | |||
}; | |||
|
|||
const onSubmit = async ({ hint }: FormData) => { | |||
await setIsLoading(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need this await
.
@@ -194,6 +198,7 @@ export const FlowRecoveryKeyHint = ({ | |||
<button | |||
className="cta-primary cta-xl w-full mt-6 mb-4" | |||
type="submit" | |||
disabled={account.loading} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this check now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching! This should be the isLoading
state.
@@ -119,7 +120,11 @@ export const Modal = ({ | |||
<button | |||
className={classNames('mx-2 flex-1', confirmBtnClassName)} | |||
data-testid="modal-confirm" | |||
onClick={(event) => onConfirm()} | |||
onClick={(event) => { | |||
setIsLoading(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does every instance of us using a modal across the codebase close after this function completes? Asking since setIsLoading(false)
isn't called here so I'd want to double check that doesn't cause any problems 🤔 This modal is used in SubPlat too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll add the loading state as an optional prop and control the loading state from the onConfirm
function that's passed in from UnitRowRecoveryKey
.
…very key flow Because: * We want to prevent users from clicking on submit buttons multiple times while account updates are in progress, and also provide users with feedback that the form has been submitted. * Clicking on the confirm password button multiple times would result in an error banner "Account recovery key already exists" * Clicking multiple times on the "remove" button from the "delete account recovery key" modal would send multiple key deleted emails This commit: * Disable submit button while password confirmation and key creation are in progress * Disable modal confirmation button while submit function is in progress Closes #FXA-7551
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with newest push! Thanks for sticking with it.
Because
This pull request
Issue that this pull request solves
Closes: #FXA-7551
Checklist
Put an
x
in the boxes that applyScreenshots (Optional)
Screen.Recording.2023-06-08.at.10.37.34.AM.mov
Other information (Optional)
Any other information that is important to this pull request.