-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add focus on initial render to Form Error List #1328
Merged
VincentSmedinga
merged 20 commits into
develop
from
feature/DES-793-add-autofocus-to-form-error-list
Jul 19, 2024
Merged
feat: Add focus on initial render to Form Error List #1328
VincentSmedinga
merged 20 commits into
develop
from
feature/DES-793-add-autofocus-to-form-error-list
Jul 19, 2024
Conversation
This file contains 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
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 9, 2024 10:49
Destroyed
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 10, 2024 08:09
Destroyed
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 10, 2024 08:11
Destroyed
Co-authored-by: Aram <[email protected]>
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 10, 2024 13:02
Destroyed
Co-authored-by: Aram <[email protected]>
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 12, 2024 10:17
Destroyed
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 12, 2024 11:02
Destroyed
…tps://github.com/Amsterdam/design-system into feature/DES-793-add-autofocus-to-form-error-list
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 12, 2024 11:04
Destroyed
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 17, 2024 07:50
Destroyed
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 17, 2024 07:53
Destroyed
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 17, 2024 11:37
Destroyed
VincentSmedinga
previously approved these changes
Jul 17, 2024
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 17, 2024 11:40
Destroyed
…ari for Mac" This reverts commit 51bd3b6.
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 19, 2024 08:42
Destroyed
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 19, 2024 08:45
Destroyed
VincentSmedinga
approved these changes
Jul 19, 2024
github-actions
bot
temporarily deployed
to
demo-DES-793-add-autofocus-to-form-error-list
July 19, 2024 09:10
Destroyed
VincentSmedinga
deleted the
feature/DES-793-add-autofocus-to-form-error-list
branch
July 19, 2024 09:15
Merged
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.
This adds focus on initial render to Form Error List, as prescribed by gov.uk.
I had to split the component in 2 parts. One part sets the document title, creates a state and returns early if there are no errors.
The second part is what renders when the component does receive a list of errors.
These parts had to be separated because the early return caused the hooks used (useRef, useImparitiveHandle, useEffect) to be called conditionally, which isn't allowed by the rules of hooks.
The
hasFocusedOnce
state is necessary to prevent the component receiving focus every time it's shown on screen. React Hook Form validates on submit and revalidates on change, which causes the component to appear while your typing. You don't want to move focus from the input you're typing in to the Form Error List in those cases.