From 5c6c607ea42e4cbbd1255bf88776990ccb6af887 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 7 Feb 2025 21:09:08 +0100 Subject: [PATCH] Move focus upwards when pressing Escape --- gdn-app/src/App.vue | 10 ++++++++++ gdn-app/src/util.ts | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/gdn-app/src/App.vue b/gdn-app/src/App.vue index 7b1e56e..37903e1 100644 --- a/gdn-app/src/App.vue +++ b/gdn-app/src/App.vue @@ -2,8 +2,18 @@ import CNavbar from "./components/CNavbar.vue"; import CNote from "./components/CNote.vue"; import { useUiStore } from "./stores/ui"; +import { pathAncestor } from "./util"; const ui = useUiStore(); + +window.addEventListener("keypress", (ev) => { + if (document.activeElement !== document.body) return; + + if (ev.key === "Escape") { + ui.focusPath = pathAncestor(ui.focusPath); + return; + } +});