From 624e912f2b320a6653c2d8990c2b22994b70eac6 Mon Sep 17 00:00:00 2001 From: Christoph Brandau Date: Thu, 24 Sep 2026 22:12:18 +0200 Subject: [PATCH] refactor(repo-toolbar): use single openMenu state for menus Consolidates the previous historyOpen and syncOpen booleans into a single union-typed openMenu ("history" | "sync" | null). Menu toggles, outside-click handler, Escape key handling and menu-item clicks now set/clear openMenu, and aria-expanded / class bindings were updated to reference openMenu. No user-facing behavior changes intended beyond ensuring only one menu can be open at a time and simplifying the event-handling logic. --- src/lib/RepoToolbar.svelte | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/lib/RepoToolbar.svelte b/src/lib/RepoToolbar.svelte index 68ff0de..d1b3299 100644 --- a/src/lib/RepoToolbar.svelte +++ b/src/lib/RepoToolbar.svelte @@ -49,8 +49,7 @@ export let onOpenSubmodules: () => void = () => {}; export let onOpenLfs: () => void = () => {}; - let historyOpen = false; - let syncOpen = false; + let openMenu: "history" | "sync" | null = null; let toolbarElement: HTMLDivElement; $: isGerman = language === "de"; @@ -65,18 +64,18 @@ : "Push"; function runHistoryAction(action: () => void) { - historyOpen = false; + openMenu = null; action(); } function handleWindowClick(event: MouseEvent) { - if (toolbarElement && !toolbarElement.contains(event.target as Node)) { historyOpen = false; syncOpen = false; } + if (toolbarElement && !toolbarElement.contains(event.target as Node)) openMenu = null; } function handleWindowKeydown(event: KeyboardEvent) { - if (event.key === "Escape" && historyOpen) { + if (event.key === "Escape" && openMenu) { event.stopPropagation(); - historyOpen = false; + openMenu = null; } } @@ -144,15 +143,15 @@ {/if}
- - {#if syncOpen} + {#if openMenu === "sync"} {/if}
@@ -187,12 +186,12 @@
- {#if historyOpen} + {#if openMenu === "history"}