From e445f2e3a43fe4be5cb2fb6c417ba719a82c90bf Mon Sep 17 00:00:00 2001 From: Rowin <20298291+GitRowin@users.noreply.github.com> Date: Mon, 8 May 2023 19:57:54 +0200 Subject: [PATCH] fix: call focus with focusVisible set to false (#9861) * fix: call focus with focusVisible set to false fixes #9002 * Update .changeset/lovely-rings-thank.md * Update packages/kit/src/runtime/client/client.js --------- Co-authored-by: Rich Harris --- .changeset/lovely-rings-thank.md | 5 +++++ packages/kit/src/runtime/client/client.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/lovely-rings-thank.md diff --git a/.changeset/lovely-rings-thank.md b/.changeset/lovely-rings-thank.md new file mode 100644 index 000000000000..b99def7934d8 --- /dev/null +++ b/.changeset/lovely-rings-thank.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: use `focusVisible: false` to prevent unwanted focus ring on navigation diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 837e00980d16..503608742adb 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -1908,7 +1908,8 @@ function reset_focus() { const tabindex = root.getAttribute('tabindex'); root.tabIndex = -1; - root.focus({ preventScroll: true }); + // @ts-expect-error + root.focus({ preventScroll: true, focusVisible: false }); // restore `tabindex` as to prevent `root` from stealing input from elements if (tabindex !== null) {