Blur live search input after emiting 'search' event

- Ensures that the drop-down disappears from screen

Refs #228
This commit is contained in:
Will Abson
2016-06-28 15:31:22 +01:00
parent 12c98a831e
commit b3a5cdabe9
2 changed files with 5 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
</label>
<div [class]="getTextFieldHolderClassName()">
<input class="mdl-textfield__input" [type]="inputType" [autocomplete]="getAutoComplete()" data-automation-id="search_input"
id="searchControl" [ngFormControl]="searchControl" [(ngModel)]="searchTerm" (focus)="onFocus($event)"
#searchInput id="searchControl" [ngFormControl]="searchControl" [(ngModel)]="searchTerm" (focus)="onFocus($event)"
(blur)="onBlur($event)">
<label class="mdl-textfield__label" for="searchControl">{{'SEARCH.CONTROL.LABEL' | translate}}</label>
</div>

View File

@@ -16,7 +16,7 @@
*/
import { Control, Validators } from '@angular/common';
import { Component, Input, Output, EventEmitter, AfterViewInit } from '@angular/core';
import { Component, Input, Output, ElementRef, EventEmitter, AfterViewInit, ViewChild } from '@angular/core';
import { AlfrescoPipeTranslate, AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component';
@@ -58,6 +58,8 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
searchControl: Control;
@ViewChild('searchInput', {}) searchInput: ElementRef;
@Input()
autocompleteSearchTerm = '';
@@ -114,7 +116,7 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
this.searchChange.emit({
value: this.searchTerm
});
// this.router.navigate(['Search', term]);
this.searchInput.nativeElement.blur();
}
}