@@ -132,7 +132,6 @@ export class VscodeSelectBase extends VscElement {
132132 */
133133 @property ( { type : Array } )
134134 set options ( opts : Option [ ] ) {
135- // this._options = opts.map((op, index) => ({...op, index}));
136135 this . _opts . populate ( opts ) ;
137136 }
138137 get options ( ) : Option [ ] {
@@ -153,10 +152,6 @@ export class VscodeSelectBase extends VscElement {
153152 @property ( { reflect : true } )
154153 position : 'above' | 'below' = 'below' ;
155154
156- // /** @internal */
157- // @property ({type: Number, attribute: true, reflect: true})
158- // override tabIndex = 0;
159-
160155 @queryAssignedElements ( {
161156 flatten : true ,
162157 selector : 'vscode-option' ,
@@ -259,13 +254,6 @@ export class VscodeSelectBase extends VscElement {
259254 /** @internal */
260255 protected _multiple = false ;
261256
262- /**
263- * @internal
264- * Quick-searchable map for searching a value in the options list.
265- * Keys are the options values, values are the option indexes.
266- */
267- protected _valueOptionIndexMap : { [ key : string ] : number } = { } ;
268-
269257 private _isHoverForbidden = false ;
270258 private _disabled = false ;
271259 private _originalTabIndex : number | undefined = undefined ;
@@ -307,7 +295,6 @@ export class VscodeSelectBase extends VscElement {
307295
308296 protected _setStateFromSlottedElements ( ) {
309297 const optionElements = this . _assignedOptions ?? [ ] ;
310- this . _valueOptionIndexMap = { } ;
311298 this . _opts . clear ( ) ;
312299
313300 optionElements . forEach ( ( el ) => {
@@ -343,6 +330,58 @@ export class VscodeSelectBase extends VscElement {
343330
344331 protected async _createAndSelectSuggestedOption ( ) { }
345332
333+ protected _toggleComboboxDropdown ( ) {
334+ this . _opts . filterPattern = '' ;
335+ this . open = ! this . open ;
336+ }
337+
338+ protected _scrollActiveElementToTop ( ) {
339+ this . _optionListScrollPos = Math . floor (
340+ this . _opts . relativeActiveIndex * OPT_HEIGHT
341+ ) ;
342+ }
343+
344+ private async _adjustOptionListScrollPos (
345+ direction : 'down' | 'up' ,
346+ optionIndex : number
347+ ) {
348+ let numOpts = this . _opts . numOfVisibleOptions ;
349+ const suggestedOptionVisible = this . _isSuggestedOptionVisible ;
350+
351+ if ( suggestedOptionVisible ) {
352+ numOpts += 1 ;
353+ }
354+
355+ if ( numOpts <= VISIBLE_OPTS ) {
356+ return ;
357+ }
358+
359+ this . _isHoverForbidden = true ;
360+ window . addEventListener ( 'mousemove' , this . _onMouseMove ) ;
361+
362+ const ulScrollTop = this . _optionListScrollPos ;
363+ const liPosY = optionIndex * OPT_HEIGHT ;
364+
365+ const fullyVisible =
366+ liPosY >= ulScrollTop &&
367+ liPosY <= ulScrollTop + VISIBLE_OPTS * OPT_HEIGHT - OPT_HEIGHT ;
368+
369+ if ( direction === 'down' ) {
370+ if ( ! fullyVisible ) {
371+ this . _optionListScrollPos =
372+ optionIndex * OPT_HEIGHT - ( VISIBLE_OPTS - 1 ) * OPT_HEIGHT ;
373+ }
374+ }
375+
376+ if ( direction === 'up' ) {
377+ if ( ! fullyVisible ) {
378+ this . _optionListScrollPos = Math . floor (
379+ this . _opts . relativeActiveIndex * OPT_HEIGHT
380+ ) ;
381+ }
382+ }
383+ }
384+
346385 //#region event handlers
347386 protected _onFaceClick ( ) : void {
348387 this . open = ! this . open ;
@@ -362,12 +401,6 @@ export class VscodeSelectBase extends VscElement {
362401 window . removeEventListener ( 'mousemove' , this . _onMouseMove ) ;
363402 } ;
364403
365- // TODO
366- protected _toggleComboboxDropdown ( ) {
367- this . _opts . filterPattern = '' ;
368- this . open = ! this . open ;
369- }
370-
371404 protected _onComboboxButtonClick ( ) : void {
372405 this . _toggleComboboxDropdown ( ) ;
373406 }
@@ -435,53 +468,6 @@ export class VscodeSelectBase extends VscElement {
435468 }
436469 }
437470
438- protected _scrollActiveElementToTop ( ) {
439- this . _optionListScrollPos = Math . floor (
440- this . _opts . relativeActiveIndex * OPT_HEIGHT
441- ) ;
442- }
443-
444- private async _adjustOptionListScrollPos (
445- direction : 'down' | 'up' ,
446- optionIndex : number
447- ) {
448- let numOpts = this . _opts . numOfVisibleOptions ;
449- const suggestedOptionVisible = this . _isSuggestedOptionVisible ;
450-
451- if ( suggestedOptionVisible ) {
452- numOpts += 1 ;
453- }
454-
455- if ( numOpts <= VISIBLE_OPTS ) {
456- return ;
457- }
458-
459- this . _isHoverForbidden = true ;
460- window . addEventListener ( 'mousemove' , this . _onMouseMove ) ;
461-
462- const ulScrollTop = this . _optionListScrollPos ;
463- const liPosY = optionIndex * OPT_HEIGHT ;
464-
465- const fullyVisible =
466- liPosY >= ulScrollTop &&
467- liPosY <= ulScrollTop + VISIBLE_OPTS * OPT_HEIGHT - OPT_HEIGHT ;
468-
469- if ( direction === 'down' ) {
470- if ( ! fullyVisible ) {
471- this . _optionListScrollPos =
472- optionIndex * OPT_HEIGHT - ( VISIBLE_OPTS - 1 ) * OPT_HEIGHT ;
473- }
474- }
475-
476- if ( direction === 'up' ) {
477- if ( ! fullyVisible ) {
478- this . _optionListScrollPos = Math . floor (
479- this . _opts . relativeActiveIndex * OPT_HEIGHT
480- ) ;
481- }
482- }
483- }
484-
485471 protected _onArrowUpKeyDown ( ) : void {
486472 if ( this . open ) {
487473 if ( this . _opts . activeIndex <= 0 && ! ( this . combobox && this . creatable ) ) {
0 commit comments