Skip to content

Commit

Permalink
revert: fix(chips): Do not throw error if chip set becomes empty (#5300)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiomkar authored Dec 3, 2019
1 parent 5e45d77 commit d10e8cd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
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

0 comments on commit d10e8cd

Please sign in to comment.