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:
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import { api, type DiagnosticsLevel } from "../lib/api";
|
||||
import { levelInForce } from "../lib/diagnostics";
|
||||
import { focusIsUnclaimed } from "../lib/useFocusKeeper";
|
||||
import { updateMeCache, useMe } from "../lib/useMe";
|
||||
import { Button } from "./ui/Button";
|
||||
import InlineNotice from "./ui/InlineNotice";
|
||||
@@ -61,7 +62,7 @@ export default function DiagnosticsSettings() {
|
||||
const from = closedFrom.current;
|
||||
if (!from || from.isConnected) return;
|
||||
closedFrom.current = null;
|
||||
if (document.activeElement && document.activeElement !== document.body) return;
|
||||
if (!focusIsUnclaimed()) return;
|
||||
pickerRef.current?.querySelector<HTMLElement>('[aria-pressed="true"]')?.focus();
|
||||
});
|
||||
const watchFocus = () => {
|
||||
|
||||
Reference in New Issue
Block a user