Skip to content

Commit 3939bb1

Browse files
authored
fix(material/slider): dragEnd not being emitted (#26289)
The `dragStart` and `dragEnd` events were being emitted in the `_fixValue` method, however the call to `_fixValue` was removed from the ending sequence in #26215. This meant that the `dragEnd` event was no longer being emitted. These changes move the `dragStart` and `dragEnd` events into the pointer down/up handlers instead since emitting them has nothing to do with fixing the value. Fixes #26285.
1 parent 66a93b9 commit 3939bb1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/material/slider/slider-input.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
365365

366366
if (!this.disabled) {
367367
this._handleValueCorrection(event);
368+
this.dragStart.emit({source: this, parent: this._slider, value: this.value});
368369
}
369370
}
370371

@@ -406,10 +407,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
406407
const impreciseValue =
407408
fixedPercentage * (this._slider.max - this._slider.min) + this._slider.min;
408409
const value = Math.round(impreciseValue / step) * step;
409-
410410
const prevValue = this.value;
411-
const dragEvent = {source: this, parent: this._slider, value: value};
412-
this._isActive ? this.dragStart.emit(dragEvent) : this.dragEnd.emit(dragEvent);
413411

414412
if (value === prevValue) {
415413
// Because we prevented UI updates, if it turns out that the race
@@ -440,10 +438,11 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
440438
}
441439

442440
_onPointerUp(): void {
443-
this._isActive = false;
444-
setTimeout(() => {
445-
this._updateWidthInactive();
446-
});
441+
if (this._isActive) {
442+
this._isActive = false;
443+
this.dragEnd.emit({source: this, parent: this._slider, value: this.value});
444+
setTimeout(() => this._updateWidthInactive());
445+
}
447446
}
448447

449448
_clamp(v: number): number {

0 commit comments

Comments
 (0)