diff --git a/src/app/components/dropdown/dropdown.html b/src/app/components/dropdown/dropdown.html index 5dc01e7..3359dd7 100644 --- a/src/app/components/dropdown/dropdown.html +++ b/src/app/components/dropdown/dropdown.html @@ -3,12 +3,12 @@ } -
- - @if (!isOpen()) { + (input)="onSearch($event)" (click)="handleInputClick($event)" (mousedown)="handleInputMouseDown()" (beforeinput)="preprocessInputContent($event)">{{ this.initialInputText() }} + } @else { {{ selectedLabel() }} } keyboard_arrow_down diff --git a/src/app/components/dropdown/dropdown.ts b/src/app/components/dropdown/dropdown.ts index d2ec326..481a254 100644 --- a/src/app/components/dropdown/dropdown.ts +++ b/src/app/components/dropdown/dropdown.ts @@ -38,7 +38,7 @@ export interface DropdownOption { '[class.open]': 'isOpen()', tabindex: '0', '(click)': 'toggle()', - '(focus)': 'onFocus($event)', + '(focus)': 'onFocus()', '(mousedown)': 'onMouseDown($event)', '(keydown)': 'onKeyDown($event)', '(keydown.enter)': 'onEnter($event)', @@ -79,9 +79,6 @@ export class Dropdown implements OnInit { if (!isDropdownOpen) { if (untracked(this.inputFocusMode)) this.inputFocusMode.set(false); this.searchQuery.set(''); - - let currentValue = untracked(this.normalizedOptions).find((o) => o.value === this.value()); - if (currentValue) this.searchInput()!.nativeElement.innerText = currentValue.label; } }); } @@ -115,6 +112,11 @@ export class Dropdown implements OnInit { return opts.filter((o) => o.label.toLowerCase().normalize('NFKD').includes(query)); }); + initialInputText = computed