small fixes for PR

This commit is contained in:
lotte
2018-08-03 17:39:47 +02:00
parent 11f4befceb
commit e7ea6294d7
13 changed files with 135 additions and 29 deletions

View File

@@ -80,6 +80,11 @@ export class InputSuggestionsComponent {
*/
selectedIndex = -1;
/**
* True when the dropdown should not reopen
*/
blockReopen = false;
/**
* Reference to the input field component
*/
@@ -162,13 +167,25 @@ export class InputSuggestionsComponent {
}
/**
* Make sure that if a suggestion is clicked, the suggestions dropdown closes and the focus moves to the input field
* Make sure that if a suggestion is clicked, the suggestions dropdown closes, does not reopen and the focus moves to the input field
*/
onClickSuggestion(data) {
this.clickSuggestion.emit(data);
this.close();
this.blockReopen = true;
this.queryInput.nativeElement.focus();
return false;
}
/**
* Finds new suggestions when necessary
* @param data The query value to emit
*/
find(data) {
if (!this.blockReopen) {
this.findSuggestions.emit(data);
}
this.blockReopen = false;
}
}