[BUGFIX] Check powermail JS validation in submit race-condition handler#120
Open
kitzberger wants to merge 1 commit intoin2code-de:masterfrom
Open
[BUGFIX] Check powermail JS validation in submit race-condition handler#120kitzberger wants to merge 1 commit intoin2code-de:masterfrom
kitzberger wants to merge 1 commit intoin2code-de:masterfrom
Conversation
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>
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
The
#submitListenerrace-condition handler callsform.submit()directly, which bypasses powermail's JavaScript validation submit event listener entirely (form.submit()does not fire thesubmitevent).The existing
reportValidity()check (added in 8b96e25) only covers native HTML5 validation, but always returnstruewhen the form has anovalidateattribute — 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
powermail_form_errorCSS class (set by powermail's JS validation framework when any field has errors) alongside the existingreportValidity()check.Both checks are extracted into a
#hasValidationErrors()helper method.Co-Authored-By: Oz oz-agent@warp.dev