Repository navigation
[BUGFIX] Don't take over form submit for form identification - #82
Merged
Merged
Conversation
With data-lux-form-identification="true" or "submitButton", LUX prevented the native submit and submitted the form itself after a delay via form.submit() or submitButton.click(), to keep the tracking request from being cancelled by the page navigation. This led to: - double submits if another script also takes over the submit (e.g. powermail_cond 13.0.2) - forms being sent although a JavaScript validation stopped the submit, because event.defaultPrevented was not respected - other submit handlers being skipped, as form.submit() does not fire a submit event The tracking request is now sent with navigator.sendBeacon(), which survives the page navigation, and the native submit is not touched any more. "submitButton" behaves like "true" and is kept for backwards compatibility. "preventDefault" is unchanged and still processes the workflow response. The same applies to form conversions of A/B tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
For forms with
data-lux-form-identification="true"or"submitButton", LUX prevented the native submit and sent the form itself after 500 ms viaform.submit()orsubmitButton.click(). The delay was there to keep the tracking request from being cancelled by the page navigation.This conflicts with other scripts:
event.defaultPreventedwas ignored. Forms that a JavaScript validation had stopped were still submitted after the delay.form.submit()does not fire asubmitevent.Solution
true/submitButton: The form values are sent vianavigator.sendBeacon()(same POST request as before). The native submit is not touched any more, so there is no delay.navigator.sendBeacon()is not available or can't queue the request (returnsfalse, e.g. when the size limit is exceeded), the request is sent with the existing XHR (ajaxConnection()) instead.submitButtonnow behaves liketrueand is kept for backwards compatibility. The native submit includes the submitter, which was the reason for this mode (typo3/cms-form).preventDefault: unchanged. The submit is stopped, and the XHR with workflow callback still runs.delaySubmit()andformDelayStopare removed. The documentation and TypoScript comments are updated.Behaviour change
For
true/submitButton, workflow responses of theformListeningRequestare not processed any more. Before, they could only run in the 500 ms before the page change. For workflows on submit,preventDefaultis the documented way.Tests (local LUX environment, Chrome, requests checked in the httpd access log)
true+ another script prevents the submit and callsform.submit()formListeningRequest, LUX no longer callsform.submit()submitButtontrue+ validation blocks the submitpreventDefaultLux.min.js/modern/chunks/Lux.mjsonly contain this change: a rebuild of the unchanged source is identical to the committed files.make test-unit: 281 tests OK🤖 Generated with Claude Code