implemented autocomplete for filter in kanban
All checks were successful
Build Docker Image / Docker-Build (push) Successful in 2m22s
Build Docker Image / Clean-Registry (push) Successful in -8s

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-03-17 09:55:11 +01:00
parent 3927898c9b
commit 22094e7ccc
2 changed files with 35 additions and 16 deletions

View File

@@ -4,13 +4,15 @@
let {
autofocus = false,
getCandidates = dummyGetCandidates,
onCommit = dummyOnCommit,
onSelect = dummyOnSelect,
candidate = $bindable({ display : '' })
} = $props();
const ignore = ['ArrowLeft','ArrowRight'];
let candidate = $state({ display : '' });
//let candidate = $state({ display : '' });
let selected = $state([]);
let candidates = $derived(getCandidates(candidate.display));
@@ -36,6 +38,8 @@
// either the selected candidate or
// an anonymous object with the entered text in the display field
console.warn(`onCommit(${JSON.stringify(candidate)}) not overridden!`);
// if the method returns true, the field will be cleared after committing
return true;
}
function dummyOnSelect(candidate){
@@ -78,8 +82,7 @@
if (ev.key == 'Enter') {
candidates = [];
selected = [];
onCommit(candidate);
candidate = { display : '' };
if (onCommit(candidate)) candidate = { display : '' };
}
return false;
}
@@ -97,15 +100,15 @@
</script>
<style>
div { position : relative }
span { position : relative }
select { position : absolute; top: 30px; left: 3px; }
select { background: black; color: orange; border: 1px solid orange; border-radius: 5px; }
option:checked { background: orange; color: black; }
</style>
<div>
<input type="text" bind:value={candidate.display} {onkeyup} />
<span>
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} />
{#if candidates && candidates.length > 0}
<select bind:value={selected} {ondblclick} multiple tabindex="-1">
{#each candidates as candidate,i}
@@ -113,4 +116,4 @@
{/each}
</select>
{/if}
</div>
</span>