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

CommentFileSizeAuthor
#2 3166204-2.patch1.15 KBmglaman

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new1.15 KB

This fixed interactions with other modules that do JavaScript on the checkout form.

scottsawyer’s picture

I'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.

  • jsacksick committed 1f2caaf on 8.x-1.x authored by mglaman
    Issue #3166204 by mglaman: Stop using HTMLFormElement.submit().
    
jsacksick’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.