Skip to content

Commit d7d8526

Browse files
authored
refactor(material/core): resolve flakes in ripple tests (#27371)
Fixes some flakes that have shown up in the ripple tests. It seems that sometimes the browser doesn't assign the `changedTouches` in tests which leads to flakiness.
1 parent 0d499a3 commit d7d8526

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,14 @@ export class RippleRenderer implements EventListenerObject {
382382

383383
// Use `changedTouches` so we skip any touches where the user put
384384
// their finger down, but used another finger to tap the element again.
385-
const touches = event.changedTouches;
386-
387-
for (let i = 0; i < touches.length; i++) {
388-
this.fadeInRipple(touches[i].clientX, touches[i].clientY, this._target.rippleConfig);
385+
const touches = event.changedTouches as TouchList | undefined;
386+
387+
// According to the typings the touches should always be defined, but in some cases
388+
// the browser appears to not assign them in tests which leads to flakes.
389+
if (touches) {
390+
for (let i = 0; i < touches.length; i++) {
391+
this.fadeInRipple(touches[i].clientX, touches[i].clientY, this._target.rippleConfig);
392+
}
389393
}
390394
}
391395
}

0 commit comments

Comments
 (0)