Click to close search dropdown
This commit is contained in:
		
							parent
							
								
									61e8892204
								
							
						
					
					
						commit
						82a4212b72
					
				| @ -2,9 +2,7 @@ | |||||||
|   <div class="d-flex"> |   <div class="d-flex"> | ||||||
|     <div class="search-box-container mr-2"> |     <div class="search-box-container mr-2"> | ||||||
|       <input (focus)="focus$.next($any($event).target.value)" (click)="click$.next($any($event).target.value)" formControlName="searchText" type="text" class="form-control" i18n-placeholder="search-form.searchbar-placeholder" placeholder="Explore the full Bitcoin ecosystem"> |       <input (focus)="focus$.next($any($event).target.value)" (click)="click$.next($any($event).target.value)" formControlName="searchText" type="text" class="form-control" i18n-placeholder="search-form.searchbar-placeholder" placeholder="Explore the full Bitcoin ecosystem"> | ||||||
|        |       <app-search-results #searchResults [hidden]="dropdownHidden" [results]="typeAhead$ | async" (selectedResult)="selectedResult($event)"></app-search-results> | ||||||
|       <app-search-results #searchResults [results]="typeAhead$ | async" (selectedResult)="selectedResult($event)"></app-search-results> |  | ||||||
|      |  | ||||||
|     </div> |     </div> | ||||||
|     <div> |     <div> | ||||||
|       <button [disabled]="isSearching" type="submit" class="btn btn-block btn-primary"> |       <button [disabled]="isSearching" type="submit" class="btn btn-block btn-primary"> | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import { Component, OnInit, ChangeDetectionStrategy, EventEmitter, Output, ViewChild, HostListener } from '@angular/core'; | import { Component, OnInit, ChangeDetectionStrategy, EventEmitter, Output, ViewChild, HostListener, ElementRef } from '@angular/core'; | ||||||
| import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||||||
| import { Router } from '@angular/router'; | import { Router } from '@angular/router'; | ||||||
| import { AssetsService } from '../../services/assets.service'; | import { AssetsService } from '../../services/assets.service'; | ||||||
| @ -23,6 +23,16 @@ export class SearchFormComponent implements OnInit { | |||||||
|   isTypeaheading$ = new BehaviorSubject<boolean>(false); |   isTypeaheading$ = new BehaviorSubject<boolean>(false); | ||||||
|   typeAhead$: Observable<any>; |   typeAhead$: Observable<any>; | ||||||
|   searchForm: FormGroup; |   searchForm: FormGroup; | ||||||
|  |   dropdownHidden = false; | ||||||
|  | 
 | ||||||
|  |   @HostListener('document:click', ['$event']) | ||||||
|  |   onDocumentClick(event) { | ||||||
|  |     if (this.elementRef.nativeElement.contains(event.target)) { | ||||||
|  |       this.dropdownHidden = false; | ||||||
|  |     } else { | ||||||
|  |       this.dropdownHidden = true; | ||||||
|  |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   regexAddress = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,100}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100})$/; |   regexAddress = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,100}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100})$/; | ||||||
|   regexBlockhash = /^[0]{8}[a-fA-F0-9]{56}$/; |   regexBlockhash = /^[0]{8}[a-fA-F0-9]{56}$/; | ||||||
| @ -45,6 +55,7 @@ export class SearchFormComponent implements OnInit { | |||||||
|     private electrsApiService: ElectrsApiService, |     private electrsApiService: ElectrsApiService, | ||||||
|     private apiService: ApiService, |     private apiService: ApiService, | ||||||
|     private relativeUrlPipe: RelativeUrlPipe, |     private relativeUrlPipe: RelativeUrlPipe, | ||||||
|  |     private elementRef: ElementRef, | ||||||
|   ) { } |   ) { } | ||||||
| 
 | 
 | ||||||
|   ngOnInit() { |   ngOnInit() { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user