File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 9797 }
9898
9999 function renderOptions ( query ) {
100- const q = ( query || '' ) . toLowerCase ( ) ;
101- const filtered = allOptions . filter ( o => o . selected || o . textLower . includes ( q ) ) ;
100+ const tokens = String ( query || '' )
101+ . toLowerCase ( )
102+ . trim ( )
103+ . split ( / \s + / ) // split by any whitespace
104+ . filter ( Boolean ) ; // remove empty tokens
105+
106+ const filtered = allOptions . filter ( o => {
107+ if ( o . selected ) return true ; // always keep selected visible
108+ if ( tokens . length === 0 ) return true ; // no filter -> show all
109+ // match if ALL tokens are contained in the label (order-independent)
110+ return tokens . every ( t => o . textLower . includes ( t ) ) ;
111+ } ) ;
112+
102113 // Rebuild options while preserving selection
103114 selectEl . innerHTML = '' ;
104115 for ( const o of filtered ) {
You can’t perform that action at this time.
0 commit comments