added simple shared topic autocompletion component

This commit is contained in:
2026-07-03 10:54:21 +02:00
parent aaab04596d
commit f19059164e
3 changed files with 198 additions and 0 deletions
@@ -0,0 +1,59 @@
<div class="topic-autocomplete">
<mat-form-field appearance="outline" class="topic-field">
<mat-label>{{ label() }}</mat-label>
<input
matInput
[placeholder]="placeholder()"
[formControl]="searchControl"
[matAutocomplete]="auto"
(click)="$event.preventDefault()"
(keydown.enter)="submitCurrentValue(); $event.preventDefault()"
(keydown.tab)="onKeydownTab($any($event))" />
@if (searchControl.value.trim()) {
<button
mat-icon-button
matSuffix
type="button"
color="primary"
aria-label="Thema hinzufügen"
(click)="submitCurrentValue()">
<mat-icon>add</mat-icon>
</button>
}
@if (searchControl.value) {
<button
mat-icon-button
matSuffix
type="button"
aria-label="Suche löschen"
(click)="clear()">
<mat-icon>close</mat-icon>
</button>
}
<mat-autocomplete
#auto="matAutocomplete"
(optionSelected)="selectTopic($event.option.value)">
@if (loading()) {
<mat-option disabled>
<mat-spinner diameter="18"></mat-spinner>
<span>Lade Themen...</span>
</mat-option>
}
@for (topic of topics(); track topic) {
<mat-option [value]="topic">{{ topic }}</mat-option>
}
@if (
!loading() &&
searchControl.value.trim().length >= minCharacters() &&
topics().length === 0
) {
<mat-option disabled>Keine passenden Themen gefunden.</mat-option>
}
</mat-autocomplete>
</mat-form-field>
</div>