Skip to content

Commit

Permalink
Remove appending hash behaviour when error summary link clicked (#1435)
Browse files Browse the repository at this point in the history
Remove appending hash behaviour when error summary link clicked
  • Loading branch information
hannalaakso authored Jun 6, 2019
2 parents ffe284a + e43c04a commit ff37796
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@

🔧 Fixes:

- Stop appending hash when error summary link clicked

This prevents incorrectly focusing the form element with the hash id, instead of the error summary, when form is re-submitted with the hash in the URL and there are further errors.

([PR #1435](https://github.com/alphagov/govuk-frontend/pull/1435))

- Fix settings layer being implicitly dependant on itself.

([PR #1381](https://github.com/alphagov/govuk-frontend/pull/1381))
Expand Down
10 changes: 0 additions & 10 deletions src/components/error-summary/error-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ ErrorSummary.prototype.focusTarget = function ($target) {
return false
}

// Prefer using the history API where possible, as updating
// window.location.hash causes the viewport to jump to the input briefly
// before then scrolling to the label/legend in IE10, IE11 and Edge (as tested
// in Edge 17).
if (window.history.pushState) {
window.history.pushState(null, null, '#' + inputId)
} else {
window.location.hash = inputId
}

// Scroll the legend or label into view *before* calling focus on the input to
// avoid extra scrolling in browsers that don't support `preventScroll` (which
// at time of writing is most of them...)
Expand Down
4 changes: 2 additions & 2 deletions src/components/error-summary/error-summary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ describe('Error Summary', () => {
expect(legendOrLabelOffsetFromTop).toEqual(0)
})

it('updates the hash in the URL', async () => {
it('does not include a hash in the URL', async () => {
const hash = await page.evaluate(() => window.location.hash)
expect(hash).toBe(`#${inputId}`)
expect(hash).toBe('')
})
})
})

0 comments on commit ff37796

Please sign in to comment.