add focus to search when you click icon

This commit is contained in:
Mads Rasmussen
2018-09-25 12:53:00 +02:00
parent 54cc6f4968
commit 2a784719ce
2 changed files with 16 additions and 5 deletions

View File

@@ -24,12 +24,13 @@
vm.clearSearch = clearSearch; vm.clearSearch = clearSearch;
vm.handleKeyUp = handleKeyUp; vm.handleKeyUp = handleKeyUp;
vm.closeSearch = closeSearch; vm.closeSearch = closeSearch;
vm.focusSearch = focusSearch;
function onInit() { function onInit() {
vm.searchQuery = ""; vm.searchQuery = "";
vm.searchResults = []; vm.searchResults = [];
vm.hasResults = false; vm.hasResults = false;
vm.focusSearch = true; focusSearch();
backdropService.open(); backdropService.open();
} }
@@ -48,12 +49,19 @@
* Clears the search query * Clears the search query
*/ */
function clearSearch() { function clearSearch() {
vm.focusSearch = false;
vm.searchQuery = ""; vm.searchQuery = "";
vm.searchResults = [];
vm.hasResults = false;
focusSearch();
}
/**
* Add focus to the search field
*/
function focusSearch() {
vm.searchHasFocus = false;
$timeout(function(){ $timeout(function(){
vm.focusSearch = true; vm.searchHasFocus = true;
vm.searchResults = [];
vm.hasResults = false;
}); });
} }

View File

@@ -24,6 +24,9 @@
font-size: 22px; font-size: 22px;
color: @gray-7; color: @gray-7;
padding-left: 20px; padding-left: 20px;
display: flex;
align-items: center;
height: 70px;
} }
.umb-search-input.umb-search-input { .umb-search-input.umb-search-input {