File tree 2 files changed +24
-2
lines changed
projects/igniteui-angular/src/lib/select
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -1618,6 +1618,22 @@ describe('igxSelect', () => {
1618
1618
tick ( 500 ) ;
1619
1619
fixture . detectChanges ( ) ;
1620
1620
} ) ) ;
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
+ } ) ) ;
1621
1637
} ) ;
1622
1638
describe ( 'Positioning tests: ' , ( ) => {
1623
1639
const defaultWindowToListOffset = 5 ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import { IgxSelectItemComponent } from './select-item.component';
18
18
import { SelectPositioningStrategy } from './select-positioning-strategy' ;
19
19
20
20
import { 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' ;
22
22
import { IgxSelectItemNavigationDirective } from './select-navigation.directive' ;
23
23
import { CancelableEventArgs } from '../core/utils' ;
24
24
import { IgxLabelDirective } from '../directives/label/label.directive' ;
@@ -272,7 +272,13 @@ export class IgxSelectComponent extends IgxDropDownComponent implements IgxSelec
272
272
this . scrollToItem ( this . selectedItem ) ;
273
273
}
274
274
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
+
276
282
private setSelection ( item : IgxDropDownItemBase ) {
277
283
if ( item && item . value !== undefined && item . value !== null ) {
278
284
this . selection . set ( this . id , new Set ( [ item ] ) ) ;
You can’t perform that action at this time.
0 commit comments