Compare commits

...

4 commits

Author SHA1 Message Date
c6abf633f8
feat: select table entries on doubleclick
All checks were successful
Visitenbuch CI / test (push) Successful in 2m22s
Visitenbuch CI / release (push) Has been skipped
2024-05-16 20:19:55 +02:00
88a5040f9c
fix: autocomplete not closing on tab 2024-05-16 19:42:26 +02:00
cdb344609c
fix: remove process.on hooks (not necessary) 2024-05-16 18:47:16 +02:00
4a3155c33a
fix: close autocomplete on defocus 2024-05-16 18:45:22 +02:00
4 changed files with 33 additions and 34 deletions

View file

@ -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

View file

@ -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<string, () => 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}
<div bind:this={listElm} class="autocomplete-list" use:floatingContent>
<div bind:this={listElm} class="autocomplete-list" tabindex="-1" use:floatingContent>
{#each filteredItems as item, i}
<div
class="autocomplete-list-item"
@ -344,7 +336,12 @@
{#if clearBtn && selection}
<div class="absolute bottom-0 right-0 h-full flex items-center">
<IconButton cls="" path={mdiClose} title="Löschen" on:click={clearSelection} />
<IconButton
cls=""
path={mdiClose}
tabindex={-1}
title="Löschen"
on:click={clearSelection} />
</div>
{/if}
</div>

View file

@ -1,4 +1,6 @@
<script lang="ts">
import { goto } from "$app/navigation";
import type { RouterOutput } from "$lib/shared/trpc";
import { formatDate } from "$lib/shared/util";
@ -39,6 +41,7 @@
class="transition-colors hover:bg-neutral-content/10"
class:done={entry.execution?.done}
class:priority={entry.current_version.priority}
on:dblclick={() => { void goto("/entry/" + entry.id); }}
>
<td
><a

View file

@ -1,4 +1,6 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { mdiFilter } from "@mdi/js";
import { URL_ENTRIES } from "$lib/shared/constants";
@ -34,6 +36,7 @@
<tr
class="transition-colors hover:bg-neutral-content/10"
class:p-hidden={patient.hidden}
on:dblclick={() => { void goto("/patient/" + patient.id); }}
>
<td
><a