Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

feat(chips): Make chip exit on trailing icon click optional #2893

Merged
merged 15 commits into from
Jun 15, 2018

Conversation

bonniezhou
Copy link
Contributor

@bonniezhou bonniezhou commented Jun 6, 2018

Fixes #2869.

Taking name suggestions to shorten shouldRemoveOnTrailingIconClick....

@codecov-io
Copy link

codecov-io commented Jun 6, 2018

Codecov Report

Merging #2893 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2893      +/-   ##
=========================================
+ Coverage    98.3%   98.3%   +<.01%     
=========================================
  Files         101     101              
  Lines        4363    4375      +12     
  Branches      563     564       +1     
=========================================
+ Hits         4289    4301      +12     
  Misses         74      74
Impacted Files Coverage Δ
packages/mdc-chips/chip/index.js 77.96% <100%> (+1.6%) ⬆️
packages/mdc-chips/chip/foundation.js 98.76% <100%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9f5560...75220f0. Read the comment docs.

@@ -276,6 +277,8 @@ Method Signature | Description
--- | ---
`isSelected() => boolean` | Returns true if the chip is selected
`setSelected(selected: boolean) => void` | Sets the chip's selected state
`shouldRemoveOnTrailingIconClick() => boolean` | Returns whether a trailing icon click should trigger exit/removal of the chip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be getShouldRemove... to complement setShouldRemove...?

demos/chips.html Outdated
function resetInputChipSet() {
inputChipSetComponent.destroy();
if (this.checked) {
inputChipSetComponent = new mdc.chips.MDCChipSet(inputChipSetEl, undefined, (chipEl) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use function, not => (IE 11)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh, nice catch

`isSelected() => boolean` | Proxies to the foundation's `isSelected` method
`beginExit() => void` | Begins the exit animation which leads to removal of the chip

Property | Value Type | Description
--- | --- | ---
`foundation` | MDCChipFoundation | The foundation
`shouldRemoveOnTrailingIconClick` | Boolean | Proxies to the foundation's `shouldRemoveOnTrailingIconClick`/`setShouldRemoveOnTrailingIconClick` methods
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add get to the foundation method name in the description.

Also, an additional thought: add a sentence here explaining that if this is set to false, manually call beginExit on the chip component to control when to remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, added as a NOTE to stick with having one line per table entry

this.adapter_.addClass(cssClasses.CHIP_EXIT);
if (this.shouldRemoveOnTrailingIconClick_) {
// Begins the exit animation which leads to removal of the chip
this.adapter_.addClass(cssClasses.CHIP_EXIT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurs to me that this is effectively doing the same thing that beginExit on the component is doing. Do you think we should create a beginExit foundation method and proxy to it from the component's method, so that both can reuse the same code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that but realized that's actually more code?
...But I guess it makes sense pattern-wise. Ok I'll update.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably is more code ultimately, but in this case the trade-off is avoiding repeating the same logic across modules which risks skew later.

`ripple` | `MDCRipple` | The `MDCRipple` instance for the root element that `MDCChip` initializes
>_NOTE_: If `shouldRemoveOnTrailingIconClick` is set to false, you must manually call `beginExit()` on the chip to remove it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add empty line between table and blockquote

@bonniezhou bonniezhou merged commit 9178d46 into master Jun 15, 2018
@bonniezhou bonniezhou deleted the feat/chips/exit-optional branch June 15, 2018 19:02
@trimox
Copy link
Contributor

trimox commented Jul 6, 2018

@bonniezhou Offering name suggestion, removable.

@bonniezhou
Copy link
Contributor Author

I think that could be misinterpreted as whether you can remove the chip at all, not whether it will be removed automatically upon click. :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants