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
|
// Focus the target so that keyboard inputs are sent to the dropdown
|
||||||
(e.target as HTMLElement | undefined)?.focus();
|
(e.target as HTMLElement | undefined)?.focus();
|
||||||
|
|
||||||
if (menuListEntry.ref) menuListEntry.ref.isOpen = true;
|
if (menuListEntry.ref) {
|
||||||
else throw new Error("The menu bar floating menu has no associated ref");
|
menuListEntry.ref.isOpen = true;
|
||||||
}
|
entries = entries;
|
||||||
|
} else {
|
||||||
function unFocusEntry(menuListEntry: MenuListEntry, e: FocusEvent) {
|
throw new Error("The menu bar floating menu has no associated ref");
|
||||||
const blurTarget = (e.target as HTMLElement | undefined)?.closest("[data-menu-bar-input]");
|
}
|
||||||
if (blurTarget !== self && menuListEntry.ref) menuListEntry.ref.isOpen = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|
@ -80,7 +79,6 @@
|
||||||
<div class="entry-container">
|
<div class="entry-container">
|
||||||
<div
|
<div
|
||||||
on:click={(e) => clickEntry(entry, e)}
|
on:click={(e) => clickEntry(entry, e)}
|
||||||
on:blur={(e) => unFocusEntry(entry, e)}
|
|
||||||
on:keydown={(e) => entry.ref?.keydown(e, false)}
|
on:keydown={(e) => entry.ref?.keydown(e, false)}
|
||||||
class="entry"
|
class="entry"
|
||||||
class:open={entry.ref?.isOpen}
|
class:open={entry.ref?.isOpen}
|
||||||
|
|
@ -95,7 +93,15 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if entry.children && entry.children.length > 0}
|
{#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}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue