Problem/Motivation
Submitting the form when using Accept.JS uses HTMLFormElement.submit
// Submit the form.
var $primaryButton = $form.find(':input.button--primary');
$form.append('<input type="hidden" name="_triggering_element_name" value="' + $primaryButton.attr('name') + '" />');
$form.append('<input type="hidden" name="_triggering_element_value" value="' + $primaryButton.val() + '" />');
$form.get(0).submit({ 'populated': true });
This is actually a really bad thing. Per the documentation (https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit) this prevents submit handlers from firing.
There may be other modules that have to do work and prevent form submission, like our work for address validation with AvaTax in #2986063: Port the address validation
Steps to reproduce
Proposed resolution
Do what we do in Braintree $form.trigger('submit', { 'tokenized' : true });
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
mglamanThis fixed interactions with other modules that do JavaScript on the checkout form.
Comment #3
scottsawyerI've been having problems with AcceptJs submitting before AvaTax can validate the address. Unfortunately, this patch did not fix the problem completely. I haven't figured out exactly what's going on, but when address validation opens it's modal, a call is made to Authorize, which clears the credit card number ( single page checkout flow ). Not sure if that is a feature or a bug, but it's annoying.
With patch, at least it no longer submits the form, which is all kinds of bad.
Comment #5
jsacksick commentedCommitted.