Skip to content

[BUGFIX] Check powermail JS validation in submit race-condition handler#120

Open
kitzberger wants to merge 1 commit intoin2code-de:masterfrom
kitzberger:bugfix/js-validation-bypass
Open

[BUGFIX] Check powermail JS validation in submit race-condition handler#120
kitzberger wants to merge 1 commit intoin2code-de:masterfrom
kitzberger:bugfix/js-validation-bypass

Conversation

@kitzberger
Copy link
Contributor

Problem

The #submitListener race-condition handler calls form.submit() directly, which bypasses powermail's JavaScript validation submit event listener entirely (form.submit() does not fire the submit event).

The existing reportValidity() check (added in 8b96e25) only covers native HTML5 validation, but always returns true when the form has a novalidate attribute — i.e. when native validation is disabled via TypoScript (validation.native = 0).

This means: when using only JS client validation (validation.client = 1, validation.native = 0), powermail's field-level validation errors are shown on blur, but clicking submit still sends the form to the server.

Fix

  • Adds a check for the powermail_form_error CSS class (set by powermail's JS validation framework when any field has errors) alongside the existing reportValidity() check.
  • Also adds the validation check to the direct-submit path (when no form element is focused), which previously had no validation guard at all.

Both checks are extracted into a #hasValidationErrors() helper method.

Co-Authored-By: Oz oz-agent@warp.dev

The #submitListener race-condition handler calls form.submit() directly,
which bypasses powermail's JavaScript validation submit event listener.

The existing reportValidity() check only covers native HTML5 validation,
but always returns true when the form has a "novalidate" attribute (i.e.
when native validation is disabled via TypoScript validation.native = 0).

This adds a check for the "powermail_form_error" CSS class which is set
by powermail's JS validation framework when any field has errors. This
covers the case where only JS client validation is active (validation.client = 1,
validation.native = 0).

Also adds the validation check to the direct-submit path (when no form
element is focused), which previously had no validation guard at all.

Co-Authored-By: Oz <oz-agent@warp.dev>
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.

1 participant