File tree Expand file tree Collapse file tree
src/includes/vscode-select Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -331,14 +331,18 @@ export class OptionListController implements ReactiveController {
331331 }
332332
333333 activateDefault ( ) {
334- if ( this . _multiSelect && this . _selectedIndexes . size > 0 ) {
335- const indexes = this . _selectedIndexes . values ( ) ;
336- const first = indexes . next ( ) ;
337- this . _activeIndex = first . value ? first . value : 0 ;
338- }
339-
340- if ( ! this . _multiSelect && this . _selectedIndex > - 1 ) {
341- this . _activeIndex = this . _selectedIndex ;
334+ if ( this . _multiSelect ) {
335+ if ( this . _selectedIndexes . size > 0 ) {
336+ const indexes = this . _selectedIndexes . values ( ) ;
337+ const first = indexes . next ( ) ;
338+ this . _activeIndex = first . value ? first . value : 0 ;
339+ }
340+ } else {
341+ if ( this . _selectedIndex > - 1 ) {
342+ this . _activeIndex = this . _selectedIndex ;
343+ } else {
344+ this . _activeIndex = 0 ;
345+ }
342346 }
343347
344348 this . _host . requestUpdate ( ) ;
Original file line number Diff line number Diff line change @@ -207,17 +207,7 @@ export class VscodeSelectBase extends VscElement {
207207 if ( changedProperties . has ( 'open' ) ) {
208208 if ( this . open ) {
209209 this . _opts . activateDefault ( ) ;
210-
211- if ( ! this . _multiple && ! this . combobox ) {
212- const activeOption = this . _opts . getActiveOption ( ) ;
213- const filteredActiveIndex = activeOption ?. relativeIndex ?? - 1 ;
214-
215- if ( filteredActiveIndex > VISIBLE_OPTS - 1 ) {
216- this . _optionListScrollPos = Math . floor (
217- filteredActiveIndex * OPT_HEIGHT
218- ) ;
219- }
220- }
210+ this . _scrollActiveElementToTop ( ) ;
221211
222212 window . addEventListener ( 'click' , this . _onClickOutside ) ;
223213 } else {
You can’t perform that action at this time.
0 commit comments