fix(keys): scroll to top when selecting a namespace

The selection is written with history.replaceState, so the page kept its
scroll position: picking a namespace with fewer keys after scrolling down
left the window past the end of the new list, looking empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ccandClaude Opus 5.5 committed 2026-12-03 16:49:34 +01:00
1 parent d5add62829
commit 8ee1fdb61a
1 file changed
+5
+5
View File
@@ -544,6 +544,11 @@ export default function Keys() {
if (ns) next.set("ns", ns);
else next.delete("ns");
window.history.replaceState(null, "", `?${next.toString()}`);
// A new namespace is a new list: start it from the top, or a shorter
// list leaves the page scrolled past its end and looking empty. The
// tree stays in view: it is sticky beside the list, or above it on
// narrow screens.
window.scrollTo({ top: 0 });
}, []);
// A namespace with no (matching) keys falls back to all keys.
const activeNs = findNamespace(keyTree, selectedNs) ? selectedNs : "";