From 46e0f6cdfcde9300f0f0b508cbb8cf5184f60da3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 9 Jul 2020 17:52:49 -0400 Subject: [PATCH] immediately run search only of search form starts off being visble (LH#14) Signed-off-by: Galen Charlton --- .../app/staff/acq/provider/provider-results.component.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-results.component.ts index b981b7f59c..1c670b0964 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-results.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, AfterViewInit, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {Component, OnInit, AfterViewInit, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core'; import {Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; @@ -27,6 +27,7 @@ export class ProviderResultsComponent implements OnInit { @Output('desireSummarize') summarize: EventEmitter = new EventEmitter(); constructor( + private elementRef: ElementRef, private router: Router, private route: ActivatedRoute, private net: NetService, @@ -48,7 +49,15 @@ export class ProviderResultsComponent implements OnInit { } ngAfterViewInit() { - setTimeout(x => this.providerSearchForm.submitSearch()); + // check if we're visible; if we are, we've + // likely come in directly from the main Provider Search + // menu item and should go ahead and submit the + // form with default values + // see: https://stackoverflow.com/questions/37843907/angular2-is-there-a-way-to-know-when-a-component-is-hidden + const elm = this.elementRef.nativeElement; + if (elm.offsetParent !== null) { + setTimeout(x => this.providerSearchForm.submitSearch()); + } } doSearch(search: AcqProviderSearch) { -- 2.11.0