Skip to content
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

Prevent rage clicking on checkout steps submit button #15710

Merged
merged 2 commits into from Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions themes/_core/js/checkout.js
Expand Up @@ -34,6 +34,7 @@ function setUpCheckout() {
setUpPayment();

handleCheckoutStepChange();
handleSubmitButton();
}

function handleCheckoutStepChange() {
Expand Down Expand Up @@ -71,6 +72,17 @@ function handleCheckoutStepChange() {
);
}

function handleSubmitButton() {
// prevents rage clicking on submit button and related issues
const submitSelector = '.js-current-step button[type="submit"]';
$(document).on('click', submitSelector, function () {
$(this).addClass('disabled');
$('input[required]').on('invalid', function (e) {
$(submitSelector).removeClass('disabled');
});
});
}

$(document).ready(() => {
if ($('#checkout').length === 1) {
setUpCheckout();
Expand Down
18 changes: 9 additions & 9 deletions themes/core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/core.js.map

Large diffs are not rendered by default.

41 changes: 30 additions & 11 deletions themes/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion themes/package.json
Expand Up @@ -18,4 +18,4 @@
"webpack": "^4.17.0",
"webpack-cli": "^3.1.0"
}
}
}