From 717e9c861aae6d42cc46f144a1724dea3e786de6 Mon Sep 17 00:00:00 2001 From: locriacyber <74560659+locriacyber@users.noreply.github.com> Date: Sat, 11 Feb 2023 22:38:34 +0000 Subject: [PATCH] Svelte: Fix part of MenuBarInput (#982) Fix MenuBarInput Fix menubar - remove dead code Amend minor code style --- .../widgets/inputs/MenuBarInput.svelte | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend-svelte/src/components/widgets/inputs/MenuBarInput.svelte b/frontend-svelte/src/components/widgets/inputs/MenuBarInput.svelte index e8d40450..39b60aab 100644 --- a/frontend-svelte/src/components/widgets/inputs/MenuBarInput.svelte +++ b/frontend-svelte/src/components/widgets/inputs/MenuBarInput.svelte @@ -35,13 +35,12 @@ // Focus the target so that keyboard inputs are sent to the dropdown (e.target as HTMLElement | undefined)?.focus(); - if (menuListEntry.ref) menuListEntry.ref.isOpen = true; - else throw new Error("The menu bar floating menu has no associated ref"); - } - - function unFocusEntry(menuListEntry: MenuListEntry, e: FocusEvent) { - const blurTarget = (e.target as HTMLElement | undefined)?.closest("[data-menu-bar-input]"); - if (blurTarget !== self && menuListEntry.ref) menuListEntry.ref.isOpen = false; + if (menuListEntry.ref) { + menuListEntry.ref.isOpen = true; + entries = entries; + } else { + throw new Error("The menu bar floating menu has no associated ref"); + } } onMount(() => { @@ -80,7 +79,6 @@
clickEntry(entry, e)} - on:blur={(e) => unFocusEntry(entry, e)} on:keydown={(e) => entry.ref?.keydown(e, false)} class="entry" class:open={entry.ref?.isOpen} @@ -95,7 +93,15 @@ {/if}
{#if entry.children && entry.children.length > 0} - + (entry.ref.isOpen = e.detail)} + open={entry.ref?.isOpen || false} + entries={entry.children || []} + direction="Bottom" + minWidth={240} + drawIcon={true} + bind:this={entry.ref} + /> {/if}
{/each}