Conversation
|
🚀 Storybook preview deployed: https://pub-dc6d99acd6874e2aaff6219dd8a13ae2.r2.dev/PR-5264/index.html |
guillerot
force-pushed
the
feat/form-focus-first-invalid-on-submit
branch
from
August 21, 2026 15:13
662420e to
2b8eea4
Compare
guillerot
marked this pull request as ready for review
August 24, 2026 14:59
guillerot
force-pushed
the
feat/form-focus-first-invalid-on-submit
branch
from
August 24, 2026 15:03
2b8eea4 to
dccc652
Compare
… focusInvalidOnSubmit by default
JeSuisCharlie1
previously approved these changes
Aug 24, 2026
Contributor
|
Pushing it our of 22.0 so we can properly discuss it and find the best approach. |
jeremie-lucca
dismissed
JeSuisCharlie1’s stale review
September 9, 2026 16:12
The base branch was changed.
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.
Description
form[luForm]can now move focus to the first invalid field when the form is submitted while invalid, so keyboard and screen reader users are led straight to the error (WCAG 3.3.1). The behavior is opt-in via a newfocusInvalidOnSubmitboolean input (defaultfalse).The behavior is DOM-based on purpose: after the
submitevent,afterNextRenderlets the app's own submit handler run first (typicallymarkAllAsTouched) and change detection apply the validity state; then, if the host<form>carriesng-invalid, the innermost.ng-invalidelement is resolved and focused. When that element is not natively focusable (custom control hosts likelu-simple-select), the first focusable descendant is focused instead, then scrolled into view.Working with CSS state classes rather than injecting
FormGroupDirective/NgFormkeeps it agnostic: it covers reactive forms andngModelalike, and needs no wiring in consuming apps.Points to discuss before undrafting:
Validated end-to-end in Cleemy Procurement with the same logic as a local directive (supplier creation form: submit via click and via Enter both land focus on the first invalid field).
Contribution
npm run buildOKnpm run lintOKFunctional review