Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
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
6 changes: 0 additions & 6 deletions packages/mdc-chips/chip-set/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ export class MDCChipSetFoundation extends MDCFoundation<MDCChipSetAdapter> {
this.adapter_.removeChipAtIndex(index);
const maxIndex = this.adapter_.getChipListCount() - 1;
const nextIndex = Math.min(index, maxIndex);

// Early exit if there are no other chips in the set
if (nextIndex < 0) {
return;
}

this.removeFocusFromChipsExcept_(nextIndex);
// After removing a chip, we should focus the trailing action for the next chip.
this.adapter_.focusChipTrailingActionAtIndex(nextIndex);
Expand Down
9 changes: 0 additions & 9 deletions test/unit/mdc-chips/mdc-chip-set.foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,6 @@ test('#handleChipRemoval gives focus to the next chip', () => {
td.verify(mockAdapter.focusChipTrailingActionAtIndex(1));
});

test('#handleChipRemoval does not throw error if chip set is left empty', () => {
const {foundation, mockAdapter} = setupTest();
td.when(mockAdapter.getChipListCount()).thenReturn(0);
td.when(mockAdapter.getIndexOfChipById('chipA')).thenReturn(0);

foundation.handleChipRemoval('chipA');
td.verify(mockAdapter.focusChipTrailingActionAtIndex(-1), {times: 0});
});

function setupChipNavigationTest(chipIds, isRTL=false) {
const {foundation, mockAdapter} = setupTest();
td.when(mockAdapter.getIndexOfChipById(td.matchers.isA(String))).thenDo((id) => {
Expand Down