File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @zazuko/yasgui " : minor
3+ ---
4+
5+ This adds a clear button for the endpoint field.
Original file line number Diff line number Diff line change 9797 display : none ;
9898 }
9999 }
100+
101+ .clearEndpointBtn {
102+ border : 1px solid #d1d1d1 ;
103+ background-color : #d1d1d1 ;
104+ color : #505050 ;
105+ border-radius : 3px ;
106+ cursor : pointer ;
107+
108+ padding : 4px 8px ;
109+ margin : 4px ;
110+
111+ display : flex ;
112+ align-items : center ;
113+ justify-content : center ;
114+
115+ opacity : 1 ;
116+ transition : opacity ease-in 200ms ;
117+
118+ & :hover {
119+ opacity : 0.8 ;
120+ }
121+ }
100122}
Original file line number Diff line number Diff line change @@ -86,10 +86,20 @@ export class EndpointSelect extends EventEmitter {
8686 // Create field
8787 this . inputField = document . createElement ( "input" ) ;
8888 addClass ( this . inputField , "autocomplete" ) ;
89- // Clear the query string when clicking on the input field
90- this . inputField . addEventListener ( "focusin" , ( ) => ( this . inputField . value = "" ) ) ;
89+ this . inputField . value = this . value ;
9190 autocompleteWrapper . appendChild ( this . inputField ) ;
9291
92+ // Create clear button
93+ const clearBtn = document . createElement ( "button" ) ;
94+ clearBtn . title = "Clear endpoint" ;
95+ addClass ( clearBtn , "clearEndpointBtn" ) ;
96+ clearBtn . innerText = "✖" ;
97+ clearBtn . addEventListener ( "click" , ( ) => {
98+ this . inputField . value = "" ;
99+ this . inputField . focus ( ) ;
100+ } ) ;
101+ this . container . appendChild ( clearBtn ) ;
102+
93103 // Init autocomplete library
94104 new Autocomplete < CatalogueItem > ( {
95105 placeholder : "Search or add an endpoint" ,
You can’t perform that action at this time.
0 commit comments