Skip to content

Commit 1666a26

Browse files
authored
Revert "fix(a11y): activeItem out of date if active index is removed from ListKeyManager (#14407)"
This reverts commit 014dc79.
1 parent 339bd5a commit 1666a26

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

src/cdk/a11y/key-manager/list-key-manager.spec.ts

-11
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ describe('Key managers', () => {
9393
expect(keyManager.activeItem!.getLabel()).toBe('one');
9494
});
9595

96-
it('should keep the active item in sync if the active item is removed', () => {
97-
expect(keyManager.activeItemIndex).toBe(0);
98-
expect(keyManager.activeItem!.getLabel()).toBe('one');
99-
100-
itemList.items.shift();
101-
itemList.notifyOnChanges();
102-
103-
expect(keyManager.activeItemIndex).toBe(0);
104-
expect(keyManager.activeItem!.getLabel()).toBe('two');
105-
});
106-
10796
it('should start off the activeItem as null', () => {
10897
expect(new ListKeyManager([]).activeItem).toBeNull();
10998
});

src/cdk/a11y/key-manager/list-key-manager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
6767
const itemArray = newItems.toArray();
6868
const newIndex = itemArray.indexOf(this._activeItem);
6969

70-
if (newIndex !== this._activeItemIndex) {
71-
this.updateActiveItem(newIndex > -1 ? newIndex : this._activeItemIndex);
70+
if (newIndex > -1 && newIndex !== this._activeItemIndex) {
71+
this._activeItemIndex = newIndex;
7272
}
7373
}
7474
});

0 commit comments

Comments
 (0)