File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export class OptionListController implements ReactiveController {
5656 }
5757
5858 set selectedIndex ( index : number ) {
59- const op = this . getOptionByIndex ( index )
59+ const op = this . getOptionByIndex ( index ) ;
6060
6161 this . _selectedIndex = op ? index : - 1 ;
6262 this . _host . requestUpdate ( ) ;
@@ -256,10 +256,37 @@ export class OptionListController implements ReactiveController {
256256 return this . _options [ index ] ;
257257 }
258258
259+ next ( fromIndex ?: number ) : { value : InternalOption ; last : boolean } {
260+ const from = fromIndex ?? this . _activeIndex ;
261+ let last = false ;
262+
263+ let nextIndex = - 1 ;
264+
265+ for ( let i = from + 1 ; i < this . _options . length ; i ++ ) {
266+ if (
267+ this . _options [ i ] &&
268+ ! this . _options [ i ] . disabled &&
269+ this . _options [ i ] . visible
270+ ) {
271+ nextIndex = i ;
272+ break ;
273+ }
274+ }
275+
276+ const value =
277+ nextIndex > - 1 ? this . _options [ nextIndex ] : ( this . _options [ from ] ?? null ) ;
278+ last = nextIndex === - 1 ;
279+
280+ return {
281+ value,
282+ last,
283+ } ;
284+ }
285+
259286 getNextSelectableOption ( fromIndex ?: number ) : InternalOption | null {
260287 const from = fromIndex ?? this . _activeIndex ;
261288
262- if ( this . _options . length === 0 ) {
289+ /* if (this._options.length === 0) {
263290 return null;
264291 }
265292
@@ -269,7 +296,7 @@ export class OptionListController implements ReactiveController {
269296
270297 if (from !== -1 && !this._options[from + 1]) {
271298 return this._options[from];
272- }
299+ } */
273300
274301 let nextIndex = - 1 ;
275302
Original file line number Diff line number Diff line change @@ -529,14 +529,15 @@ export class VscodeSelectBase extends VscElement {
529529 return ;
530530 }
531531
532- if ( suggestedOptionVisible && this . _opts . activeIndex === numOpts - 2 ) {
532+ const nextOp = this . _opts . next ( ) ;
533+
534+ if ( suggestedOptionVisible && nextOp . last ) {
533535 this . _isPlaceholderOptionActive = true ;
534536 this . _adjustOptionListScrollPos ( 'down' , numOpts - 1 ) ;
535537 this . _opts . activeIndex = - 1 ;
536- } else if ( this . _opts . activeIndex < numOpts - 1 ) {
537- const nextOpt = this . _opts . activateNext ( ) ;
538- console . log ( nextOpt )
539- const nextSelectableIndex = nextOpt ?. relativeIndex ?? - 1 ;
538+ } else {
539+ const nextSelectableIndex = nextOp ?. value . relativeIndex ?? - 1 ;
540+ this . _opts . activeIndex = nextOp . value . index ;
540541
541542 if ( nextSelectableIndex > - 1 ) {
542543 this . _adjustOptionListScrollPos ( 'down' , nextSelectableIndex ) ;
Original file line number Diff line number Diff line change @@ -242,6 +242,7 @@ export class VscodeSingleSelect
242242 }
243243 }
244244
245+ //#region event handlers
245246 protected override _onSlotChange ( ) : void {
246247 super . _onSlotChange ( ) ;
247248
@@ -300,7 +301,7 @@ export class VscodeSingleSelect
300301 this._selectedIndex = nextIndex;
301302 this._activeIndex = nextIndex;
302303 this._value = nextIndex > -1 ? this._options[nextIndex].value : ''; */
303- this . _internals . setFormValue ( this . _value ) ;
304+ this . _internals . setFormValue ( this . _opts . value as string ) ;
304305 this . _manageRequired ( ) ;
305306 this . _dispatchChangeEvent ( ) ;
306307 }
@@ -373,6 +374,7 @@ export class VscodeSingleSelect
373374 this . _dispatchChangeEvent ( ) ;
374375 }
375376 }
377+ //#endregion
376378
377379 protected override _manageRequired ( ) {
378380 const { value} = this ;
You can’t perform that action at this time.
0 commit comments