Skip to content

Disable the swaps submit button after the first time it is clicked#10162

Merged
danjm merged 1 commit intodevelopfrom
prevent-two-submits-swaps-viewquote
Jan 19, 2021
Merged

Disable the swaps submit button after the first time it is clicked#10162
danjm merged 1 commit intodevelopfrom
prevent-two-submits-swaps-viewquote

Conversation

@danjm
Copy link
Copy Markdown
Contributor

@danjm danjm commented Jan 8, 2021

This PR prevents an accidental submission of two swaps that could be caused by clicking the submit button a second time before the user is rerouted to the awaiting swaps screen.

@danjm danjm requested a review from a team as a code owner January 8, 2021 01:55
@danjm danjm requested a review from darkwing January 8, 2021 01:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 8, 2021

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [ce22267]
Page Load Metrics (575 ± 46 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint34694794
domContentLoaded3567305749546
load3607315759546
domInteractive3557295739546

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

</div>
<SwapsFooter
onSubmit={() => {
setSubmitClicked(true)
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt Jan 14, 2021

Choose a reason for hiding this comment

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

I noticed that this never gets set back to false if the signAndSendTransactions throws an error. I artificially introduced an error and tested it out, and it just hangs with the button disabled.

We should instead show an error message and let the user retry. Or if we recognize the error as indication that the swap will almost certainly fail, then show an error and abort the swaps flow.

I think this can be dealt with separately from this PR though. This flow didn't work very well before this PR either - I don't think it's appreciably worse now.

Though it would be good to track improving this. I'd like to have a generic error page added to every flow if possible, so we have somewhere to navigate the user to explain what happened before bringing them back to home.

@danjm danjm merged commit 36ef9a2 into develop Jan 19, 2021
@danjm danjm deleted the prevent-two-submits-swaps-viewquote branch January 19, 2021 17:12
@github-actions github-actions bot locked and limited conversation to collaborators Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants