components icon indicating copy to clipboard operation
components copied to clipboard

bug(MatSlider): "showTickMarks" cash if updating mat-slider from api callback

Open chiLinh0412 opened this issue 1 year ago • 3 comments
trafficstars

Is this a regression?

  • [ ] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

``I have problem with Range slider when i need to get min, max from an API call. The console show no error but my app just freeze completely. If i remove [showTickMarks], problem solved !

slider.html <mat-slider class="filter-slider" [min]="this.soldeMin" [max]="this.soldeMax" [discrete]="true" [showTickMarks]="true"> <input matSliderStartThumb [(ngModel)]="filterSoldeMin"> <input matSliderEndThumb [(ngModel)]="filterSoldeMax"> </mat-slider>

slider.ts `` soldeMin: number = 0; soldeMax: number = 3000;

ngOnInit(): void {
    this.api.get().subscribe(res => {
        this.soldeMin = res.solde_min;
        this.soldeMax = res.solde_max;
    })
}

``

Reproduction

StackBlitz link: https://stackblitz.com/edit/qifxvd?file=src%2Fexample%2Fslider-range-example.ts,src%2Fexample%2Fslider-range-example.html,src%2Fexample%2Fslider-range-example.css Steps to reproduce: 1. 2.

Expected Behavior

App not freeze

Actual Behavior

App freeze

Environment

  • Angular: 16.2.0
  • CDK/Material: 16.2.8
  • Browser(s): Edge, Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

chiLinh0412 avatar Jul 27 '24 10:07 chiLinh0412

Please provide a reproduction to help us investigate

mmalerba avatar Aug 06 '24 17:08 mmalerba

Hello @mmalerba,

After testing, i found out the problem come from "showTickMarks" when the "max" value is too big ( ~ 50000).

https://stackblitz.com/edit/qifxvd?file=src%2Fexample%2Fslider-range-example.ts

chiLinh0412 avatar Aug 27 '24 09:08 chiLinh0412

I suspect the issue is that each tick mark is rendered out as a DOM node.

crisbeto avatar Sep 20 '24 07:09 crisbeto