Skip to content

Commit 4300f39

Browse files
committed
fix(material/core): ripples not being removed if container is hidden (#26096)
Fixes that the ripples weren't being removed if the ripple container has `display: none` on it. This is a bit of an edge case that I hit while working on a different task, but it's easy to guard against since we have all the information to know when it happens. (cherry picked from commit 374993f)
1 parent c9a5474 commit 4300f39

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/material/core/ripple/ripple-renderer.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,19 @@ export class RippleRenderer implements EventListenerObject {
153153
const userTransitionProperty = computedStyles.transitionProperty;
154154
const userTransitionDuration = computedStyles.transitionDuration;
155155

156-
// Note: We detect whether animation is forcibly disabled through CSS by the use of
157-
// `transition: none`. This is technically unexpected since animations are controlled
158-
// through the animation config, but this exists for backwards compatibility. This logic does
159-
// not need to be super accurate since it covers some edge cases which can be easily avoided by users.
156+
// Note: We detect whether animation is forcibly disabled through CSS (e.g. through
157+
// `transition: none` or `display: none`). This is technically unexpected since animations are
158+
// controlled through the animation config, but this exists for backwards compatibility. This
159+
// logic does not need to be super accurate since it covers some edge cases which can be easily
160+
// avoided by users.
160161
const animationForciblyDisabledThroughCss =
161162
userTransitionProperty === 'none' ||
162163
// Note: The canonical unit for serialized CSS `<time>` properties is seconds. Additionally
163164
// some browsers expand the duration for every property (in our case `opacity` and `transform`).
164165
userTransitionDuration === '0s' ||
165-
userTransitionDuration === '0s, 0s';
166+
userTransitionDuration === '0s, 0s' ||
167+
// If the container is 0x0, it's likely `display: none`.
168+
(containerRect.width === 0 && containerRect.height === 0);
166169

167170
// Exposed reference to the ripple that will be returned.
168171
const rippleRef = new RippleRef(this, ripple, config, animationForciblyDisabledThroughCss);

0 commit comments

Comments
 (0)