diff --git a/src/material/slider/slider-input.ts b/src/material/slider/slider-input.ts index f3b7bb015870..193ac10e4a12 100644 --- a/src/material/slider/slider-input.ts +++ b/src/material/slider/slider-input.ts @@ -365,6 +365,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA if (!this.disabled) { this._handleValueCorrection(event); + this.dragStart.emit({source: this, parent: this._slider, value: this.value}); } } @@ -406,10 +407,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA const impreciseValue = fixedPercentage * (this._slider.max - this._slider.min) + this._slider.min; const value = Math.round(impreciseValue / step) * step; - const prevValue = this.value; - const dragEvent = {source: this, parent: this._slider, value: value}; - this._isActive ? this.dragStart.emit(dragEvent) : this.dragEnd.emit(dragEvent); if (value === prevValue) { // Because we prevented UI updates, if it turns out that the race @@ -440,10 +438,11 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA } _onPointerUp(): void { - this._isActive = false; - setTimeout(() => { - this._updateWidthInactive(); - }); + if (this._isActive) { + this._isActive = false; + this.dragEnd.emit({source: this, parent: this._slider, value: this.value}); + setTimeout(() => this._updateWidthInactive()); + } } _clamp(v: number): number {