From 8ee1fdb61a8be4e82b2e0176e3b86e462f449cbc Mon Sep 17 00:00:00 2001 From: cc Date: Thu, 3 Dec 2026 16:49:34 +0100 Subject: [PATCH] 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 --- src/app/os/keys/page.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/os/keys/page.tsx b/src/app/os/keys/page.tsx index e31dc8b..48f38d6 100644 --- a/src/app/os/keys/page.tsx +++ b/src/app/os/keys/page.tsx @@ -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 : "";