-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add anchor links between error summary items and inputs #10
Merged
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
Having no control of the ids is problematic when making the error summary list link _directly_ to the element because, in the case of multi-input fields (like radios and checkboxes) we don't know what's available or what's first This is the first step towards making all error summary links behave as specified in the GOV.UK Design System https://design-system.service.gov.uk/components/error-summary/#linking-from-the-error-summary-to-each-answer Refs #9
Ruby can't validate individual elements of a date so when a date is invalid make the error summary link focus the day field
We're passing in the block arg but not using it which is making the linter complain. However, builder requires it to be explicit so it's used by #initialize instead of #html
peteryates
added
enhancement
New feature or request
accessibility
Making it easier for people with disabilities
labels
Jul 20, 2019
peteryates
added a commit
that referenced
this pull request
Jan 9, 2020
The GOV.UK Design System suggests that the anchor links in error summaries should link to actual form inputs[0], they previously linked to the error message that is associated with the field. This work adds the linking functionality to this form builder. * Errors on fields that have a single element are directly linked. These include: text inputs, telephone inputs, email inputs, url inputs, number inputs, file inputs and select boxes * Errors on date fields always link to the day. Ruby has no concept of part of a date being invalid, so we link to the first input in the group. * Errors on fields with multiple elements, namely radio buttons and check boxes, link to the first radio or checkbox. For the collection methods this happens automatically. For #govuk_radio_buttons_fieldset an extra parameter is required on the first radio button, link_errors should be set to true. Fixes #9 [0] https://design-system.service.gov.uk/components/error-summary#linking-from-the-error-summary-to-each-answer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
The GOV.UK Design System suggests that the anchor links in error summaries should link to actual form inputs, they previously linked to the error message that is associated with the field. This work adds the linking functionality to this form builder.
Errors on fields that have a single element are directly linked. These include
Errors on date fields always link to the day. Ruby has no concept of part of a date being invalid, so we link to the first input in the group.
Errors on fields with multiple elements, namely radio buttons and check boxes, link to the first radio or checkbox. For the
collection
methods this happens automatically. For#govuk_radio_buttons_fieldset
an extra parameter is required on the first radio button,link_errors
should be set to true.Fixes #9