diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 87c81a0..a7fddf5 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -31,3 +31,7 @@ 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 7a20f6d..f1a7885 100644 --- a/src/lib/components/filter/Autocomplete.svelte +++ b/src/lib/components/filter/Autocomplete.svelte @@ -166,14 +166,6 @@ 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; } @@ -193,38 +185,43 @@ } function onKeyDown(e: KeyboardEvent): void { - switch (e.key) { - case "Tab": - close(); - break; - case "ArrowDown": + let { key } = e; + if (key === "Tab" && e.shiftKey) key = "ShiftTab"; + const fnmap: Record void> = { + Tab: () => close, + ShiftTab: () => close, + ArrowDown: () => { open(); if (highlightIndex < filteredItems.length - 1) { highlightIndex++; highlight(); } - break; - case "ArrowUp": + }, + ArrowUp: () => { open(); if (highlightIndex > 0) { highlightIndex--; highlight(); } - break; - case "Escape": + }, + Escape: () => { e.stopPropagation(); if (opened) { if (inputElm) inputElm.focus(); close(); } - break; - case "Backspace": + }, + Backspace: () => { if (inputValue().length === 0) { onBackspace(); } else if (selection) { clearSelection(); } - break; + }, + }; + const fn = fnmap[key]; + if (typeof fn === "function") { + fn(); } } @@ -237,6 +234,16 @@ } } + function onBlur(): void { + if (!selection) { + if (!noAutoselect1 && filteredItems.length === 1) { + selectListItem(filteredItems[0], true); + } else { + setInputValue(""); + } + } + } + function highlight(): void { if (browser && opened) { window.setTimeout(() => { @@ -296,11 +303,12 @@ 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 4af0262..42c2990 100644 --- a/src/lib/components/table/EntryTable.svelte +++ b/src/lib/components/table/EntryTable.svelte @@ -1,6 +1,4 @@