diff --git a/src/lib/core/a11y/list-key-manager.spec.ts b/src/lib/core/a11y/list-key-manager.spec.ts index 2f6bd8657f8e..4a64bac10cd1 100644 --- a/src/lib/core/a11y/list-key-manager.spec.ts +++ b/src/lib/core/a11y/list-key-manager.spec.ts @@ -240,6 +240,16 @@ describe('Key managers', () => { expect(TAB_EVENT.defaultPrevented).toBe(false); }); + it('should activate the first item when pressing down on a clean key manager', () => { + keyManager = new ListKeyManager(itemList); + + expect(keyManager.activeItemIndex).toBeNull('Expected active index to default to null.'); + + keyManager.onKeydown(DOWN_ARROW_EVENT); + + expect(keyManager.activeItemIndex).toBe(0, 'Expected first item to become active.'); + }); + }); describe('programmatic focus', () => { diff --git a/src/lib/core/a11y/list-key-manager.ts b/src/lib/core/a11y/list-key-manager.ts index 308e10a67dca..d54bf1a1521d 100644 --- a/src/lib/core/a11y/list-key-manager.ts +++ b/src/lib/core/a11y/list-key-manager.ts @@ -16,7 +16,7 @@ export interface CanDisable { * of items, it will set the active item correctly when arrow events occur. */ export class ListKeyManager { - private _activeItemIndex: number; + private _activeItemIndex: number = null; private _activeItem: T; private _tabOut: Subject = new Subject(); private _wrap: boolean = false; diff --git a/src/lib/tabs/tab-body.spec.ts b/src/lib/tabs/tab-body.spec.ts index 4ff41baf642a..4d6840097c4a 100644 --- a/src/lib/tabs/tab-body.spec.ts +++ b/src/lib/tabs/tab-body.spec.ts @@ -169,7 +169,7 @@ describe('MdTabBody', () => { })); }); - it('it should toggle the canBeAnimated flag', () => { + it('should toggle the canBeAnimated flag', () => { let fixture: ComponentFixture; let tabBody: MdTabBody;