mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(ripple): ripples not being cleared if touch sequence is canceled (#12936)
If the browser's touch sequence gets canceled by something, the `touchend` event won't fire which means that the ripples won't be cleared from the ripple container. These changes add an extra handler to make sure that they are.
This commit is contained in:
committed by
Jeremy Elbourn
parent
cfb83a0ebc
commit
948e563ed9
@@ -110,12 +110,14 @@ export class RippleRenderer {
|
||||
this._containerElement = elementRef.nativeElement;
|
||||
|
||||
// Specify events which need to be registered on the trigger.
|
||||
this._triggerEvents.set('mousedown', this.onMousedown);
|
||||
this._triggerEvents.set('mouseup', this.onPointerUp);
|
||||
this._triggerEvents.set('mouseleave', this.onPointerUp);
|
||||
this._triggerEvents
|
||||
.set('mousedown', this.onMousedown)
|
||||
.set('mouseup', this.onPointerUp)
|
||||
.set('mouseleave', this.onPointerUp)
|
||||
|
||||
this._triggerEvents.set('touchstart', this.onTouchStart);
|
||||
this._triggerEvents.set('touchend', this.onPointerUp);
|
||||
.set('touchstart', this.onTouchStart)
|
||||
.set('touchend', this.onPointerUp)
|
||||
.set('touchcancel', this.onPointerUp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,17 @@ describe('MatRipple', () => {
|
||||
expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(0);
|
||||
}));
|
||||
|
||||
it('should clear ripples if the touch sequence is cancelled', fakeAsync(() => {
|
||||
dispatchTouchEvent(rippleTarget, 'touchstart');
|
||||
tick(enterDuration);
|
||||
expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(1);
|
||||
|
||||
dispatchTouchEvent(rippleTarget, 'touchcancel');
|
||||
tick(exitDuration);
|
||||
|
||||
expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(0);
|
||||
}));
|
||||
|
||||
it('should launch multiple ripples for multi-touch', fakeAsync(() => {
|
||||
const touchEvent = createTouchEvent('touchstart');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user