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"}