fix(nav): Back restores the focus after a click on the page's blank area

The page region is <main tabIndex=-1>, so a background click focused it and the
Back restore took that for the reader's choice. A resting place is marked and
one predicate (focusIsUnclaimed) decides "the focus is nowhere" everywhere.
This commit is contained in:
2026-09-27 14:06:16 +02:00
parent 383c85231a
commit 9bedd96774
6 changed files with 45 additions and 11 deletions
+2 -1
View File
@@ -19,6 +19,7 @@ import {
import { moduleDef } from "../lib/modules";
import type { Page } from "../lib/urlState";
import { qk } from "../lib/queryKeys";
import { focusIsUnclaimed } from "../lib/useFocusKeeper";
import { LEVEL_TAG, logClock } from "./logLineParts";
import { Button } from "./ui/Button";
import { IconButton } from "./ui/IconButton";
@@ -54,7 +55,7 @@ export default function IssueComposer({ id }: { id: string }) {
useEffect(
() => () => {
window.setTimeout(() => {
if (document.activeElement === document.body)
if (focusIsUnclaimed())
document.querySelector<HTMLElement>('nav [aria-current="page"]')?.focus();
}, 0);
},