mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Search-as-you-type drop-down should disappear when input focus is lost
Refs #173
This commit is contained in:
@@ -56,6 +56,10 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
|
||||
@Input()
|
||||
autocompleteSearchTerm = '';
|
||||
|
||||
searchActive = false;
|
||||
|
||||
searchValid = false;
|
||||
|
||||
constructor(private translate: AlfrescoTranslationService) {
|
||||
|
||||
this.searchControl = new Control(
|
||||
@@ -63,11 +67,13 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
|
||||
Validators.compose([Validators.required, Validators.minLength(3)])
|
||||
);
|
||||
|
||||
this.searchControl.valueChanges.debounceTime(400).distinctUntilChanged().subscribe(
|
||||
(value: string) => {
|
||||
this.autocompleteSearchTerm = value;
|
||||
}
|
||||
);
|
||||
this.searchControl.valueChanges.map(value => this.searchControl.valid ? value : '')
|
||||
.debounceTime(400).distinctUntilChanged().subscribe(
|
||||
(value: string) => {
|
||||
this.autocompleteSearchTerm = value;
|
||||
this.searchValid = this.searchControl.valid;
|
||||
}
|
||||
);
|
||||
|
||||
translate.addTranslationFolder('node_modules/ng2-alfresco-search');
|
||||
}
|
||||
@@ -105,4 +111,18 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
|
||||
}
|
||||
}
|
||||
|
||||
onFocus(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
this.searchActive = true;
|
||||
}
|
||||
|
||||
onBlur(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
this.searchActive = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user