Skip to content

[BUGFIX] Don't take over form submit for form identification - #82

Merged
einpraegsam merged 2 commits into
developfrom
bugfix/form-identification-double-submit
Nov 3, 2026
Merged

einpraegsam merged 2 commits into
developfrom
bugfix/form-identification-double-submit

Conversation

@sebastianstein

Copy link
Copy Markdown
Contributor

Problem

For forms with data-lux-form-identification="true" or "submitButton", LUX prevented the native submit and sent the form itself after 500 ms via form.submit() or submitButton.click(). The delay was there to keep the tracking request from being cancelled by the page navigation.

This conflicts with other scripts:

  1. Double submit: If another script also takes over the submit, the form is sent twice. Example: powermail_cond ≥ 13.0.2. On in2code.de, every powermail submit with LUX enabled was stored, mailed and posted to Slack twice (see [BUGFIX] Prevent double submit when another script handles the submit powermail_cond#134).
  2. Validation is bypassed: event.defaultPrevented was ignored. Forms that a JavaScript validation had stopped were still submitted after the delay.
  3. Other submit handlers are skipped: form.submit() does not fire a submit event.

Solution

  • true / submitButton: The form values are sent via navigator.sendBeacon() (same POST request as before). The native submit is not touched any more, so there is no delay.
  • Fallback: If navigator.sendBeacon() is not available or can't queue the request (returns false, e.g. when the size limit is exceeded), the request is sent with the existing XHR (ajaxConnection()) instead.
  • submitButton now behaves like true and 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.
  • Form conversions of A/B tests use the beacon as well.
  • delaySubmit() and formDelayStop are removed. The documentation and TypoScript comments are updated.

Behaviour change

For true / submitButton, workflow responses of the formListeningRequest are not processed any more. Before, they could only run in the 500 ms before the page change. For workflows on submit, preventDefault is the documented way.

Tests (local LUX environment, Chrome, requests checked in the httpd access log)

Scenario Before After
true + another script prevents the submit and calls form.submit() locally 1 POST, because the response came faster than the LUX delay. On in2code.de (slower response): 2 submits 1 form POST + beacon formListeningRequest, LUX no longer calls form.submit()
submitButton not tested 1 POST without delay + beacon
true + validation blocks the submit form sent anyway after the delay not sent, values tracked
preventDefault not sent, XHR + workflow callback unchanged
  • The rebuilt Lux.min.js / modern/chunks/Lux.mjs only 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

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>
@einpraegsam
einpraegsam merged commit b789b86 into develop Nov 3, 2026
9 checks passed
@einpraegsam
einpraegsam deleted the bugfix/form-identification-double-submit branch November 3, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants