Svelte: Fix part of MenuBarInput (#982)
Fix MenuBarInput Fix menubar - remove dead code Amend minor code style
This commit is contained in:
parent
91f5f74d58
commit
717e9c861a
|
|
@ -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 @@
|
|||
<div class="entry-container">
|
||||
<div
|
||||
on:click={(e) => 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}
|
||||
</div>
|
||||
{#if entry.children && entry.children.length > 0}
|
||||
<MenuList open={entry.ref?.menuIsOpen() || false} entries={entry.children || []} direction="Bottom" minWidth={240} drawIcon={true} bind:this={entry.ref} />
|
||||
<MenuList
|
||||
on:open={(e) => (entry.ref.isOpen = e.detail)}
|
||||
open={entry.ref?.isOpen || false}
|
||||
entries={entry.children || []}
|
||||
direction="Bottom"
|
||||
minWidth={240}
|
||||
drawIcon={true}
|
||||
bind:this={entry.ref}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
|
|
|
|||
Loading…
Reference in New Issue