@@ -10,11 +10,7 @@ import { property, query } from 'lit/decorators.js';
1010import { classMap } from 'lit/directives/class-map.js' ;
1111import { prefix } from '../../globals/settings' ;
1212import Close16 from '@carbon/icons/es/close/16.js' ;
13- import {
14- filter ,
15- forEach ,
16- indexOf ,
17- } from '../../globals/internal/collection-helpers' ;
13+ import { filter , forEach } from '../../globals/internal/collection-helpers' ;
1814import CDSDropdown , {
1915 DROPDOWN_KEYBOARD_ACTION ,
2016 DROPDOWN_TYPE ,
@@ -534,34 +530,11 @@ class CDSMultiSelect extends CDSDropdown {
534530 * @param direction `-1` to navigate backward, `1` to navigate forward.
535531 */
536532 protected _navigate ( direction : number ) {
537- if ( ! this . filterable ) {
538- super . _navigate ( direction ) ;
539- this . _triggerNode . classList . add ( 'no-focus-style' ) ;
540- } else {
541- // only navigate through remaining item
542- const constructor = this . constructor as typeof CDSMultiSelect ;
543- const items = this . querySelectorAll ( constructor . selectorItemResults ) ;
544- const highlightedItem = this . querySelector (
545- constructor . selectorItemHighlighted
546- ) ;
547- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
548- const highlightedIndex = indexOf ( items , highlightedItem ! ) ;
549-
550- let nextIndex = highlightedIndex + direction ;
551-
552- if ( items [ nextIndex ] ?. hasAttribute ( 'disabled' ) ) {
553- nextIndex += direction ;
554- }
555- if ( nextIndex < 0 ) {
556- nextIndex = items . length - 1 ;
557- }
558- if ( nextIndex >= items . length ) {
559- nextIndex = 0 ;
560- }
561- forEach ( items , ( item , i ) => {
562- ( item as CDSMultiSelectItem ) . highlighted = i === nextIndex ;
563- } ) ;
533+ super . _navigate ( direction ) ;
534+ if ( this . filterable ) {
564535 this . setAttribute ( 'item-clicked' , '' ) ;
536+ } else {
537+ this . _triggerNode . classList . add ( 'no-focus-style' ) ;
565538 }
566539 }
567540
0 commit comments