Skip to content

Conversation

MichaelWest22
Copy link
Collaborator

@MichaelWest22 MichaelWest22 commented Jul 12, 2025

Description

Adds support for reportValidity instead of just using checkValidity like it currently does. Because this could possible alter existing applications that don't expect their htmx activated forms to report invalid inputs and update the focus to the first invalid input currently in htmx i've put it behind a new config item. This is default browser behaviour so all users should ideally have this config turned on but having it has a config will prevent any change to existing applications while allowing users than want this the option to turn it on.

Also this change also allows disabling the report validity if you use preventDefault in the htmx:validation:failed event.

Also had to ensure that reportValidity only fires on the first invalid input so it focuses the right item.

This could replace PR #3215

Corresponding issue:
#2372

Testing

Added tests to ensure it focuses on the first input as expected with reportvalidity

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@MichaelWest22 MichaelWest22 added the ready for review Issues that are ready to be considered for merging label Jul 12, 2025
@1cg 1cg merged commit 9d598f8 into bigskysoftware:dev Jul 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Issues that are ready to be considered for merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants