helix-website icon indicating copy to clipboard operation
helix-website copied to clipboard

[360] Use submit event for form submission

Open chicharr opened this issue 1 year ago • 3 comments

Description

Form block uses

Related Issue

#360

Motivation and Context

Forms are submitted by a listener on the click event of the submit button. The payload is generated and POST'ed as a json via fetch API. This prevents the triggering of the submit event.

This behaviour prevents other features such as RUM or Conversion tracking to work automatically, as they listen to submit events

How Has This Been Tested?

  • Run the project locally.
  • On chrome browser open: https://www.hlx.live/developer/forms
  • Open developer tools -> Console and add a submit listener on the form element. document.getElementsByTagName('form')[0].addEventListener('submit', (e) => {console.log('form submitted');})
  • Scroll down to the sample form in the page, enter some data and click submit button.
  • Validate that in the browser Console, there is a message form submitted
  • Check that POST fetch request is still sent
  • Check that redirection after submit is still happening

Screenshots (if appropriate):

Types of changes

  • [X] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [X] I have signed the Adobe Open Source CLA.
  • [ ] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [X] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
  • [X] All new and existing tests passed.

chicharr avatar Aug 21 '23 13:08 chicharr