fix: avoid hashchange when resetting focus - #16985
fix: avoid hashchange when resetting focus#16985svelte-triage-bot[bot] wants to merge 2 commits into
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/cb5e69040072630be54564cbe75d9aaa70466868Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: cb5e690 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@svelte-triage-bot On Firefox and Safari the target stays document.activeElement after focus_element. The hash-routing focus test asserts BODY there. Fold the hashchange test into that existing test |
|
Updated the existing hash-routing focus test and removed the standalone hashchange test.
|
Fixes #16982.
Replace the fragment-navigation workaround in
reset_focuswith temporary programmatic focus. The target receivestabindex="-1", is focused without scrolling or a visible focus ring, and then has its original attribute restored synchronously.This preserves the sequential focus-navigation starting point without changing the URL, mutating history state, scrolling, or leaking
hashchangeevents to application listeners.The existing hash-routing focus test now also verifies that focus reset dispatches no observable
hashchange. Its focus assertions account for browser behavior: Firefox and Safari retain the fragment target asdocument.activeElement, while Chromium resets toBODY. Subsequent keyboard-navigation coverage remains intact.