Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(list-key-manager): exception when no initial active item #3431

Merged
merged 2 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/lib/core/a11y/list-key-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FakeFocusable>(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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/a11y/list-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface CanDisable {
* of items, it will set the active item correctly when arrow events occur.
*/
export class ListKeyManager<T extends CanDisable> {
private _activeItemIndex: number;
private _activeItemIndex: number = null;
private _activeItem: T;
private _tabOut: Subject<any> = new Subject();
private _wrap: boolean = false;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tabs/tab-body.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('MdTabBody', () => {
}));
});

it('it should toggle the canBeAnimated flag', () => {
it('should toggle the canBeAnimated flag', () => {
let fixture: ComponentFixture<SimpleTabBodyApp>;
let tabBody: MdTabBody;

Expand Down