Focus search on start

This commit is contained in:
Geomitron
2024-07-10 15:50:52 -05:00
parent 531f8d2c8f
commit aff1246a94
2 changed files with 4 additions and 1 deletions

View File

@@ -5,7 +5,7 @@
<!-- Search Input --> <!-- Search Input -->
<div class="flex items-center flex-1 flex-grow-[2] min-w-[21rem]"> <div class="flex items-center flex-1 flex-grow-[2] min-w-[21rem]">
<div class="form-control w-full"> <div class="form-control w-full">
<input type="text" [formControl]="searchControl" placeholder="Search..." class="input input-bordered pr-14" /> <input #searchInput type="text" [formControl]="searchControl" placeholder="Search..." class="input input-bordered pr-14" />
</div> </div>
@if (searchLoading) { @if (searchLoading) {
<span class="loading loading-spinner loading-sm self-center -ml-9"></span> <span class="loading loading-spinner loading-sm self-center -ml-9"></span>

View File

@@ -13,6 +13,8 @@ import { difficulties, difficultyDisplay, instrumentDisplay, instruments } from
}) })
export class SearchBarComponent implements OnInit, AfterViewInit { export class SearchBarComponent implements OnInit, AfterViewInit {
@ViewChild('searchInput') searchInput: ElementRef<HTMLInputElement>
@ViewChild('hasSoloSections') hasSoloSections: ElementRef<HTMLInputElement> @ViewChild('hasSoloSections') hasSoloSections: ElementRef<HTMLInputElement>
@ViewChild('hasForcedNotes') hasForcedNotes: ElementRef<HTMLInputElement> @ViewChild('hasForcedNotes') hasForcedNotes: ElementRef<HTMLInputElement>
@ViewChild('hasOpenNotes') hasOpenNotes: ElementRef<HTMLInputElement> @ViewChild('hasOpenNotes') hasOpenNotes: ElementRef<HTMLInputElement>
@@ -45,6 +47,7 @@ export class SearchBarComponent implements OnInit, AfterViewInit {
} }
ngAfterViewInit() { ngAfterViewInit() {
this.searchInput.nativeElement.focus()
this.updateDisabledControls() this.updateDisabledControls()
this.searchService.instrument.valueChanges.subscribe(() => { this.searchService.instrument.valueChanges.subscribe(() => {
this.updateDisabledControls() this.updateDisabledControls()