Skip to content

Commit

Permalink
fix(chips): Fix choice-chips leading icon being hidden (#2796)
Browse files Browse the repository at this point in the history
Add a boolean to not remove the leading icon when selected chip does not contain a checkmark.
Change the color of the leading icon when selected. Change the tests to ensure it is checking the right chips. Add test for selected chip with leading icon and no checkmark, to not
remove the leading icon.

Fixes #2728
  • Loading branch information
EstebanG23 authored May 30, 2018
1 parent d7eca82 commit 7d406fa
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
1 change: 1 addition & 0 deletions packages/mdc-chips/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

&.mdc-chip--selected {
@include mdc-theme-prop(color, $color);
@include mdc-chip-leading-icon-color($color);

&:hover {
@include mdc-theme-prop(color, $color);
Expand Down
52 changes: 27 additions & 25 deletions packages/mdc-chips/chip/mdc-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,41 +115,43 @@

// Add leading checkmark to filter chips with a leading icon

.mdc-chip__icon--leading {
transition: opacity $mdc-chip-opacity-animation-duration linear;
transition-delay: $mdc-chip-leading-icon-delay;
opacity: 1;

+ .mdc-chip__checkmark {
.mdc-chip-set--filter {
.mdc-chip__icon--leading {
transition: opacity $mdc-chip-opacity-animation-duration linear;
transition-delay: $mdc-chip-leading-icon-delay;
opacity: 1;

// Delay the checkmark transition.
transition-delay: $mdc-chip-checkmark-with-leading-icon-delay;
opacity: 0;
+ .mdc-chip__checkmark {
transition: opacity $mdc-chip-opacity-animation-duration linear;

// Delay the checkmark transition.
transition-delay: $mdc-chip-checkmark-with-leading-icon-delay;
opacity: 0;

.mdc-chip__checkmark-svg {
transition: width 0ms;
.mdc-chip__checkmark-svg {
transition: width 0ms;
}
}
}
}

.mdc-chip--selected .mdc-chip__icon--leading {
opacity: 0;
.mdc-chip--selected .mdc-chip__icon--leading {
opacity: 0;

+ .mdc-chip__checkmark {
// This ensures that the checkmark has zero width while the leading icon is still animating.
width: 0;
opacity: 1;
+ .mdc-chip__checkmark {
// This ensures that the checkmark has zero width while the leading icon is still animating.
width: 0;
opacity: 1;
}
}
}

.mdc-chip__icon--leading-hidden.mdc-chip__icon--leading {
width: 0;
.mdc-chip__icon--leading-hidden.mdc-chip__icon--leading {
width: 0;

// This ensures that the leading icon doesn't fade in while the checkmark is fading out.
opacity: 0;
// This ensures that the leading icon doesn't fade in while the checkmark is fading out.
opacity: 0;

+ .mdc-chip__checkmark {
width: $mdc-chip-leading-icon-size;
+ .mdc-chip__checkmark {
width: $mdc-chip-leading-icon-size;
}
}
}
9 changes: 5 additions & 4 deletions test/unit/mdc-chips/mdc-chip.foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ test('exports cssClasses', () => {

test('defaultAdapter returns a complete adapter implementation', () => {
verifyDefaultAdapter(MDCChipFoundation, [
'addClass', 'removeClass', 'hasClass', 'addClassToLeadingIcon', 'removeClassFromLeadingIcon',
'eventTargetHasClass', 'registerEventHandler', 'deregisterEventHandler',
'registerTrailingIconInteractionHandler', 'deregisterTrailingIconInteractionHandler',
'notifyInteraction', 'notifyTrailingIconInteraction', 'notifyRemoval',
'addClass', 'removeClass', 'hasClass', 'addClassToLeadingIcon',
'removeClassFromLeadingIcon', 'eventTargetHasClass', 'registerEventHandler',
'deregisterEventHandler', 'registerTrailingIconInteractionHandler',
'deregisterTrailingIconInteractionHandler', 'notifyInteraction',
'notifyTrailingIconInteraction', 'notifyRemoval',
'getComputedStyleValue', 'setStyleProperty',
]);
});
Expand Down

0 comments on commit 7d406fa

Please sign in to comment.