File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
projects/igniteui-angular/src/lib/select Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -1618,6 +1618,22 @@ describe('igxSelect', () => {
16181618 tick ( 500 ) ;
16191619 fixture . detectChanges ( ) ;
16201620 } ) ) ;
1621+
1622+ it ( 'Should navigate through items when dropdown is closed and initial value is passed' , fakeAsync ( ( ) => {
1623+ select . close ( ) ;
1624+ tick ( ) ;
1625+ fixture . detectChanges ( ) ;
1626+ spyOn ( select , 'navigateNext' ) . and . callThrough ( ) ;
1627+ const choices = select . children . toArray ( ) ;
1628+ select . value = choices [ 5 ] . value ;
1629+ tick ( ) ;
1630+ fixture . detectChanges ( ) ;
1631+ select . input . nativeElement . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' } ) ) ;
1632+ tick ( ) ;
1633+ fixture . detectChanges ( ) ;
1634+ expect ( select . navigateNext ) . toHaveBeenCalled ( ) ;
1635+ expect ( select . value ) . toEqual ( choices [ 6 ] . value ) ;
1636+ } ) ) ;
16211637 } ) ;
16221638 describe ( 'Positioning tests: ' , ( ) => {
16231639 const defaultWindowToListOffset = 5 ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import { IgxSelectItemComponent } from './select-item.component';
1818import { SelectPositioningStrategy } from './select-positioning-strategy' ;
1919
2020import { OverlaySettings , AbsoluteScrollStrategy } from '../services/index' ;
21- import { IGX_DROPDOWN_BASE , ISelectionEventArgs } from '../drop-down/drop-down.common' ;
21+ import { IGX_DROPDOWN_BASE , ISelectionEventArgs , Navigate } from '../drop-down/drop-down.common' ;
2222import { IgxSelectItemNavigationDirective } from './select-navigation.directive' ;
2323import { CancelableEventArgs } from '../core/utils' ;
2424import { IgxLabelDirective } from '../directives/label/label.directive' ;
@@ -272,7 +272,13 @@ export class IgxSelectComponent extends IgxDropDownComponent implements IgxSelec
272272 this . scrollToItem ( this . selectedItem ) ;
273273 }
274274
275- /** @hidden @internal */
275+ protected navigate ( direction : Navigate , currentIndex ?: number ) {
276+ if ( this . collapsed && this . selectedItem ) {
277+ this . navigateItem ( this . selectedItem . itemIndex ) ;
278+ }
279+ super . navigate ( direction , currentIndex ) ;
280+ }
281+
276282 private setSelection ( item : IgxDropDownItemBase ) {
277283 if ( item && item . value !== undefined && item . value !== null ) {
278284 this . selection . set ( this . id , new Set ( [ item ] ) ) ;
You can’t perform that action at this time.
0 commit comments