Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/slider): avoid manual fixing values on pointer up #26215

Merged
merged 4 commits into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/material/slider/slider-input.ts
Expand Up @@ -439,12 +439,11 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
}
}

_onPointerUp(event: PointerEvent): void {
_onPointerUp(): void {
this._isActive = false;
this._updateWidthInactive();
if (!this.disabled) {
this._handleValueCorrection(event);
}
setTimeout(() => {
this._updateWidthInactive();
}, 10);
mmalerba marked this conversation as resolved.
Show resolved Hide resolved
}

_clamp(v: number): number {
Expand Down Expand Up @@ -636,11 +635,13 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan
super._onPointerDown(event);
}

override _onPointerUp(event: PointerEvent): void {
super._onPointerUp(event);
override _onPointerUp(): void {
super._onPointerUp();
if (this._sibling) {
this._sibling._updateWidthInactive();
this._sibling._hostElement.classList.remove('mat-mdc-slider-input-no-pointer-events');
setTimeout(() => {
this._sibling!._updateWidthInactive();
this._sibling!._hostElement.classList.remove('mat-mdc-slider-input-no-pointer-events');
}, 10);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/material/slider/slider.spec.ts
Expand Up @@ -1686,7 +1686,7 @@ function setValueByClick(
input.focus();
dispatchPointerEvent(inputElement, 'pointerup', x, y);
dispatchEvent(input._hostElement, new Event('change'));
tick();
tick(10);
wagnermaciel marked this conversation as resolved.
Show resolved Hide resolved
}

/** Slides the MatSlider's thumb to the given value. */
Expand All @@ -1702,7 +1702,7 @@ function slideToValue(slider: MatSlider, input: MatSliderThumb, value: number) {
dispatchEvent(input._hostElement, new Event('input'));
dispatchPointerEvent(sliderElement, 'pointerup', endX, endY);
dispatchEvent(input._hostElement, new Event('change'));
tick();
tick(10);
wagnermaciel marked this conversation as resolved.
Show resolved Hide resolved
}

/** Returns the x and y coordinates for the given slider value. */
Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/material/slider.md
Expand Up @@ -167,7 +167,7 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan
// (undocumented)
_onPointerMove(event: PointerEvent): void;
// (undocumented)
_onPointerUp(event: PointerEvent): void;
_onPointerUp(): void;
// (undocumented)
_setIsLeftThumb(): void;
// (undocumented)
Expand Down Expand Up @@ -243,7 +243,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
// (undocumented)
_onPointerMove(event: PointerEvent): void;
// (undocumented)
_onPointerUp(event: PointerEvent): void;
_onPointerUp(): void;
get percentage(): number;
registerOnChange(fn: any): void;
registerOnTouched(fn: any): void;
Expand Down