From 6ce3c1d75d314f6fc0634a373bb2db4d97b78fd0 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Mon, 24 Jul 2023 10:18:00 +0900 Subject: [PATCH] [search bar] auto focus only in dashboards --- .../mining-dashboard.component.ts | 10 +++++++-- .../search-form/search-form.component.html | 2 +- .../search-form/search-form.component.ts | 21 ++++++++++++++++--- .../src/app/dashboard/dashboard.component.ts | 10 ++++++--- frontend/src/app/services/state.service.ts | 2 ++ 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/components/mining-dashboard/mining-dashboard.component.ts b/frontend/src/app/components/mining-dashboard/mining-dashboard.component.ts index df4713374..22d0e11fe 100644 --- a/frontend/src/app/components/mining-dashboard/mining-dashboard.component.ts +++ b/frontend/src/app/components/mining-dashboard/mining-dashboard.component.ts @@ -1,6 +1,7 @@ -import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; +import { AfterViewChecked, ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { SeoService } from '../../services/seo.service'; import { WebsocketService } from '../../services/websocket.service'; +import { StateService } from '../../services/state.service'; @Component({ selector: 'app-mining-dashboard', @@ -8,10 +9,11 @@ import { WebsocketService } from '../../services/websocket.service'; styleUrls: ['./mining-dashboard.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MiningDashboardComponent implements OnInit { +export class MiningDashboardComponent implements OnInit, AfterViewChecked { constructor( private seoService: SeoService, private websocketService: WebsocketService, + private stateService: StateService ) { this.seoService.setTitle($localize`:@@a681a4e2011bb28157689dbaa387de0dd0aa0c11:Mining Dashboard`); } @@ -19,4 +21,8 @@ export class MiningDashboardComponent implements OnInit { ngOnInit(): void { this.websocketService.want(['blocks', 'mempool-blocks', 'stats']); } + + ngAfterViewChecked(): void { + this.stateService.searchFocus$.next(true); + } } diff --git a/frontend/src/app/components/search-form/search-form.component.html b/frontend/src/app/components/search-form/search-form.component.html index cdfcfe015..3fc03c83a 100644 --- a/frontend/src/app/components/search-form/search-form.component.html +++ b/frontend/src/app/components/search-form/search-form.component.html @@ -1,7 +1,7 @@