Skip to content

fix(material-experimental/mdc-chips): chip removal not working if animations are disabled #18314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2020
Merged
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
10 changes: 8 additions & 2 deletions src/material-experimental/mdc-chips/chips.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
@import '@material/chips/mixins.import';
@import '../../material/core/style/layout-common';
@import '../../material/core/style/noop-animation';
@import '../../cdk/a11y/a11y';
@import '../mdc-helpers/mdc-helpers';

@include mdc-chip-without-ripple($query: $mat-base-styles-query);
@include mdc-chip-set-core-styles($query: $mat-base-styles-query);
@include _noop-animation;

.mat-mdc-chip {
// MDC uses a pointer cursor
Expand All @@ -16,6 +14,14 @@
// Required for the ripple to clip properly in Safari.
transform: translateZ(0);

&._mat-animation-noopable {
// MDC's chip removal works by toggling a class on the chip, waiting for its transitions
// to finish and emitting the remove event at the end. The problem is that if our animations
// were disabled via the `NoopAnimationsModule`, the element won't have a transition and
// `transitionend` won't fire. We work around the issue by assigning a very short transition.
transition-duration: 1ms;
Copy link
Contributor

Choose a reason for hiding this comment

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

@crisbeto in Chrome at least, you could make this even smaller, e.g. 0.0001ms

Copy link
Member Author

Choose a reason for hiding this comment

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

Anything less than 16ms is less than a frame at 60fps so people problably wouldn't notice it anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'm not sure if it will make any actual difference, I just want to make sure the delay is as small as possible since animations are supposed to be disabled. It's very possible though that the browser treats 0.0001ms and 1ms as the exact same thing

}

@include cdk-high-contrast {
outline: solid 1px;

Expand Down