@@ -63,6 +63,10 @@ export class OptionListController implements ReactiveController {
6363 }
6464
6565 set selectedIndex ( index : number ) {
66+ if ( this . _selectedIndex !== - 1 ) {
67+ this . _options [ this . _selectedIndex ] . selected ??= false ;
68+ }
69+
6670 const op = this . getOptionByIndex ( index ) ;
6771
6872 this . _selectedIndex = op ? index : - 1 ;
@@ -74,7 +78,18 @@ export class OptionListController implements ReactiveController {
7478 }
7579
7680 set selectedIndexes ( value : number [ ] ) {
81+ this . _selectedIndexes . forEach ( ( v ) => {
82+ this . _options [ v ] . selected = false ;
83+ } ) ;
84+
7785 this . _selectedIndexes = new Set ( value ) ;
86+
87+ value . forEach ( ( v ) => {
88+ if ( this . _options [ v ] !== undefined ) {
89+ this . _options [ v ] . selected = true ;
90+ }
91+ } ) ;
92+
7893 this . _host . requestUpdate ( ) ;
7994 }
8095
@@ -240,6 +255,18 @@ export class OptionListController implements ReactiveController {
240255 }
241256 }
242257
258+ expandMultiSelection ( values : string [ ] ) {
259+ values . forEach ( ( v ) => {
260+ const foundIndex = this . _indexByValue . get ( v ) ?? - 1 ;
261+
262+ if ( foundIndex !== - 1 ) {
263+ this . _selectedIndexes . add ( foundIndex ) ;
264+ }
265+ } ) ;
266+
267+ this . _host . requestUpdate ( ) ;
268+ }
269+
243270 toggleComboboxMode ( enabled : boolean ) {
244271 this . _combobox = enabled ;
245272 this . _host . requestUpdate ( ) ;
@@ -265,6 +292,8 @@ export class OptionListController implements ReactiveController {
265292 } else {
266293 this . _selectedIndexes . add ( optIndex ) ;
267294 }
295+
296+ this . _host . requestUpdate ( ) ;
268297 }
269298
270299 getActiveOption ( ) : InternalOption | null {
@@ -279,6 +308,10 @@ export class OptionListController implements ReactiveController {
279308 return this . _options [ index ] ?? null ;
280309 }
281310
311+ findOptionIndex ( value : string ) {
312+ return this . _indexByValue . get ( value ) ?? - 1 ;
313+ }
314+
282315 getOptionByValue (
283316 value : string ,
284317 includeHiddenOptions = false
0 commit comments