Skip to content

Commit 3c79855

Browse files
karajelbourn
authored andcommitted
chore(a11y): make disabled property optional (#1613)
1 parent 596d994 commit 3c79855

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/lib/core/a11y/list-key-manager.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ describe('ListKeyManager', () => {
7777
expect(items[2].focus).toHaveBeenCalledTimes(1);
7878
});
7979

80+
it('should work normally when disabled property does not exist', () => {
81+
items[0].disabled = undefined;
82+
items[1].disabled = undefined;
83+
items[2].disabled = undefined;
84+
85+
keyManager.onKeydown(DOWN_ARROW_EVENT);
86+
expect(items[0].focus).not.toHaveBeenCalled();
87+
expect(items[1].focus).toHaveBeenCalledTimes(1);
88+
expect(items[2].focus).not.toHaveBeenCalled();
89+
90+
keyManager.onKeydown(DOWN_ARROW_EVENT);
91+
expect(items[0].focus).not.toHaveBeenCalled();
92+
expect(items[1].focus).toHaveBeenCalledTimes(1);
93+
expect(items[2].focus).toHaveBeenCalledTimes(1);
94+
});
95+
8096
it('should wrap back to menu when arrow keying past items', () => {
8197
keyManager.onKeydown(DOWN_ARROW_EVENT);
8298
keyManager.onKeydown(DOWN_ARROW_EVENT);

src/lib/core/a11y/list-key-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {UP_ARROW, DOWN_ARROW, TAB} from '../core';
77
*/
88
export interface MdFocusable {
99
focus(): void;
10-
disabled: boolean;
10+
disabled?: boolean;
1111
}
1212

1313
/**

0 commit comments

Comments
 (0)