File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed
src/core/search/components/search-box Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 99 < ion-icon name ="close "> </ ion-icon >
1010 </ button >
1111 </ ion-item >
12- < ion-list class ="core-search-history with-borders ">
12+ < ion-list class ="core-search-history with-borders " [hidden] =" !historyShown " >
1313 < a ion-item text-wrap *ngFor ="let item of history " (click) ="historyClicked($event, item.searchedtext) " class ="core-clickable " tabindex ="1 ">
1414 < core-icon name ="fa-history " item-start > </ core-icon >
1515 {{item.searchedtext}}
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ ion-app.app-root core-search-box {
2323 }
2424
2525 .core-search-history {
26- display : none ;
2726 max-height : calc (-120px + 80vh );
2827 overflow-y : auto ;
2928
@@ -35,10 +34,4 @@ ion-app.app-root core-search-box {
3534 border-bottom : 0 ;
3635 }
3736 }
38-
39- form :focus-within {
40- .core-search-history {
41- display : block ;
42- }
43- }
4437}
Original file line number Diff line number Diff line change @@ -78,6 +78,19 @@ export class CoreSearchBoxComponent implements OnInit {
7878 if ( this . searchArea ) {
7979 this . loadHistory ( ) ;
8080 }
81+
82+ this . formElement . nativeElement . addEventListener ( 'focus' , ( ) => {
83+ this . historyShown = true ;
84+ } , true ) ;
85+
86+ this . formElement . nativeElement . addEventListener ( 'blur' , ( ) => {
87+ // Wait the new element to be focused.
88+ setTimeout ( ( ) => {
89+ if ( document . activeElement . closest ( 'form' ) != this . formElement . nativeElement ) {
90+ this . historyShown = false ;
91+ }
92+ } ) ;
93+ } , true ) ;
8194 }
8295
8396 /**
@@ -100,6 +113,7 @@ export class CoreSearchBoxComponent implements OnInit {
100113
101114 this . domUtils . triggerFormSubmittedEvent ( this . formElement , false , this . sitesProvider . getCurrentSiteId ( ) ) ;
102115
116+ this . historyShown = false ;
103117 this . searched = this . searchText ;
104118 this . onSubmit . emit ( this . searchText ) ;
105119 }
You can’t perform that action at this time.
0 commit comments