diff --git a/src/hooks.server.ts b/src/hooks.server.ts index a7fddf5..87c81a0 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -31,7 +31,3 @@ export const handle = sequence( authorization, createTRPCHandle({ router, createContext }), ); - -// Allow server application to exit -process.on("SIGINT", () => process.exit()); // Ctrl+C -process.on("SIGTERM", () => process.exit()); // docker stop diff --git a/src/lib/components/filter/Autocomplete.svelte b/src/lib/components/filter/Autocomplete.svelte index f1a7885..7a20f6d 100644 --- a/src/lib/components/filter/Autocomplete.svelte +++ b/src/lib/components/filter/Autocomplete.svelte @@ -166,6 +166,14 @@ if (opened) { onClose(kb); } + // select remaining item if autoselect is enabled + if (!selection) { + if (!noAutoselect1 && filteredItems.length === 1) { + selectListItem(filteredItems[0], true); + } else { + setInputValue(""); + } + } opened = false; } @@ -185,43 +193,38 @@ } function onKeyDown(e: KeyboardEvent): void { - let { key } = e; - if (key === "Tab" && e.shiftKey) key = "ShiftTab"; - const fnmap: Record void> = { - Tab: () => close, - ShiftTab: () => close, - ArrowDown: () => { + switch (e.key) { + case "Tab": + close(); + break; + case "ArrowDown": open(); if (highlightIndex < filteredItems.length - 1) { highlightIndex++; highlight(); } - }, - ArrowUp: () => { + break; + case "ArrowUp": open(); if (highlightIndex > 0) { highlightIndex--; highlight(); } - }, - Escape: () => { + break; + case "Escape": e.stopPropagation(); if (opened) { if (inputElm) inputElm.focus(); close(); } - }, - Backspace: () => { + break; + case "Backspace": if (inputValue().length === 0) { onBackspace(); } else if (selection) { clearSelection(); } - }, - }; - const fn = fnmap[key]; - if (typeof fn === "function") { - fn(); + break; } } @@ -234,16 +237,6 @@ } } - function onBlur(): void { - if (!selection) { - if (!noAutoselect1 && filteredItems.length === 1) { - selectListItem(filteredItems[0], true); - } else { - setInputValue(""); - } - } - } - function highlight(): void { if (browser && opened) { window.setTimeout(() => { @@ -303,12 +296,11 @@ on:focus={open} on:keydown={onKeyDown} on:keypress={onKeyPress} - on:blur={onBlur} use:floatingRef /> {#if opened && filteredItems.length > 0} -
+
{#each filteredItems as item, i}
- +
{/if}
diff --git a/src/lib/components/table/EntryTable.svelte b/src/lib/components/table/EntryTable.svelte index 42c2990..4af0262 100644 --- a/src/lib/components/table/EntryTable.svelte +++ b/src/lib/components/table/EntryTable.svelte @@ -1,4 +1,6 @@