Skip to content

Commit

Permalink
Merge pull request #1497 from bolt/fix/spinners-on-invalid-forms
Browse files Browse the repository at this point in the history
Fix: Don't show spinners on invalid form submissions
  • Loading branch information
I-Valchev authored Jun 17, 2020
2 parents eaa3b07 + b81d1dd commit b888b73
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions assets/js/app/patience-is-a-virtue.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import $ from 'jquery';

$('*[data-patience]').on('click', function() {
$('a[data-patience], button[data-patience]').on('click', function() {
const thisElement = $(this);
const thisIcon = thisElement.find('i');

// If we're handling a form, and the form's not valid, we can stop here
if (
$(this).attr('form') &&
!$('#' + $(this).attr('form'))[0].checkValidity()
) {
return false;
}

// Bootstrap padding / margin like `mx-2` or `pt-3`
const addedPadding = thisIcon.attr('class').match(/[mp][tblrxy]-[0-5]/i);
const newClass =
Expand All @@ -18,7 +26,7 @@ $('*[data-patience]').on('click', function() {
});

window.reEnablePatientButtons = function() {
$('*[data-patience]').each(function() {
$('*[data-original-class]').each(function() {
const thisIcon = $(this).find('i');

$(this).attr('disabled', false);
Expand Down

0 comments on commit b888b73

Please sign in to comment.