-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(chips): Expose method to begin chip exit animation #2845
Conversation
test/unit/mdc-chips/mdc-chip.test.js
Outdated
@@ -202,3 +202,9 @@ test('#isSelected proxies to foundation', () => { | |||
component.isSelected(); | |||
td.verify(mockFoundation.isSelected()); | |||
}); | |||
|
|||
test('#beginExit adds `mdc-chip--exit` class', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse constant in test description and assertion
demos/chips.html
Outdated
@@ -281,8 +285,17 @@ <h2>Custom theme</h2> | |||
root && inputChipSetEl.removeChild(root); | |||
} | |||
|
|||
function deleteLastChip(evt) { | |||
if (evt.type === 'click' || evt.key === 'Enter' || evt.keyCode === 13) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
is unnecessary; this function is only used in response to click
which already triggers on enter/space for buttons.
Codecov Report
@@ Coverage Diff @@
## master #2845 +/- ##
==========================================
+ Coverage 98.39% 98.39% +<.01%
==========================================
Files 98 98
Lines 4182 4184 +2
Branches 532 532
==========================================
+ Hits 4115 4117 +2
Misses 67 67
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nit, otherwise LGTM
demos/chips.html
Outdated
@@ -281,8 +285,15 @@ <h2>Custom theme</h2> | |||
root && inputChipSetEl.removeChild(root); | |||
} | |||
|
|||
function deleteLastChip(evt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: evt
is unused and can be omitted
This is necessary for users to allow deleting a chip without interacting with the trailing remove icon. A common use case of this is deleting the last chip by pressing the backspace key in an input.
The exit animation shrinks the chip until it's invisible. Once the animation finishes, the
MDCChip:removal
event will be fired to actually remove the chip from the page.