@@ -202,6 +202,14 @@ class CommandPalette extends Widget {
202
202
*/
203
203
refresh ( ) : void {
204
204
this . _results = null ;
205
+ if ( this . inputNode . value !== '' ) {
206
+ let clear = this . node . getElementsByClassName ( 'lm-close-icon' ) [ 0 ] as HTMLInputElement ;
207
+ clear . style . display = 'inherit'
208
+ }
209
+ else {
210
+ let clear = this . node . getElementsByClassName ( 'lm-close-icon' ) [ 0 ] as HTMLInputElement ;
211
+ clear . style . display = 'none'
212
+ }
205
213
this . update ( ) ;
206
214
}
207
215
@@ -338,6 +346,13 @@ class CommandPalette extends Widget {
338
346
return ;
339
347
}
340
348
349
+ // Clear input if the target is clear button
350
+ if ( ( event . target as HTMLElement ) . classList . contains ( "lm-close-icon" ) ) {
351
+ this . inputNode . value = '' ;
352
+ this . refresh ( ) ;
353
+ return ;
354
+ }
355
+
341
356
// Find the index of the item which was clicked.
342
357
let index = ArrayExt . findFirstIndex ( this . contentNode . children , node => {
343
358
return node . contains ( event . target as HTMLElement ) ;
@@ -1024,9 +1039,12 @@ namespace Private {
1024
1039
let wrapper = document . createElement ( 'div' ) ;
1025
1040
let input = document . createElement ( 'input' ) ;
1026
1041
let content = document . createElement ( 'ul' ) ;
1042
+ let clear = document . createElement ( 'button' ) ;
1027
1043
search . className = 'lm-CommandPalette-search' ;
1028
1044
wrapper . className = 'lm-CommandPalette-wrapper' ;
1029
1045
input . className = 'lm-CommandPalette-input' ;
1046
+ clear . className = 'lm-close-icon' ;
1047
+
1030
1048
content . className = 'lm-CommandPalette-content' ;
1031
1049
/* <DEPRECATED> */
1032
1050
search . classList . add ( 'p-CommandPalette-search' ) ;
@@ -1035,8 +1053,8 @@ namespace Private {
1035
1053
content . classList . add ( 'p-CommandPalette-content' ) ;
1036
1054
/* </DEPRECATED> */
1037
1055
input . spellcheck = false ;
1038
- input . type = 'search' ;
1039
1056
wrapper . appendChild ( input ) ;
1057
+ wrapper . appendChild ( clear ) ;
1040
1058
search . appendChild ( wrapper ) ;
1041
1059
node . appendChild ( search ) ;
1042
1060
node . appendChild ( content ) ;
0 commit comments