Skip to content
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

Remove appending hash behaviour when error summary link clicked #1435

Merged
merged 3 commits into from
Jun 6, 2019

Conversation

hannalaakso
Copy link
Member

@hannalaakso hannalaakso commented Jun 6, 2019

When error summary links were clicked, a hash with the clicked linked id would be added to the URL. As reported in #1398, if the form is submitted again with further errors, the hash stopped the error summary being focused as should happen, and instead the element with the hash id was scrolled to. This was confusing to the user, especially as they might have already corrected the error in the now focused form element.

This behaviour was prevented in GOV.UK Elements. When the error summary component was added to GOV.UK Frontend, this behaviour wasn't reintroduced as we didn't know the reason for it. We use preventDefault() to improve the user experience when the error summary links are clicked on by showing the error message above the form field, instead of scrolling down to the form field itself. We programmatically reintroduced the hash to the URL to replicate browser behaviour.

Following the bug report, the code for appending the hash is redundant and can be removed.

Fixes #1398

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1435 June 6, 2019 10:34 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1435 June 6, 2019 10:35 Inactive
hannalaakso and others added 2 commits June 6, 2019 11:36
When error summary links are clicked, this adds a hash to the URL.
As reported in #1398,
if the form is submitted again with further errors, the hash will stop
the error summary being focused as should happen and instead the element
with the hash ID is scrolled to which is confusing for the user.

This behaviour was prevented in GOV.UK Elements but we were not sure at
the time why this was necessary so it wasn't reintroduced in GOV.UK Frontend.
As we need to use preventDefault() to stop the page scrolling to the form element
itself and to show the error message above to make it clear what happened,
we programmatically reintroduced the hash to the URL to replicate browser
behaviour.

Following the bug report #1398, the code that adds the hash is redundant
and can be removed.

Co-authored-by: Oliver Byford <[email protected]>
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1435 June 6, 2019 10:37 Inactive
Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, very clear reasoning.

@NickColley NickColley added this to the v3.0.0 milestone Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants