question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(mat-slider): Max value not updating correctly when new value is 0

See original GitHub issue

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 am changing slider’s max value in my component while/after doing some works. And it seems it has a problem updating visually when new max value is 0.

Reproduction

Steps to reproduce:

  1. Define slider like this: <mat-slider min="0" [displayWith]="displayValue" [max]="maxValue" step="1" [thumbLabel]="true" [tickInterval]="1" [(ngModel)]="sliderValue" (ngModelChange)="changeSliderValue()"></mat-slider>
  2. Default sliderValue is 0, maxValue is 0.
  3. Click a button and change maxValue - let’s say to 6. Updates slider and ticks correctly.
  4. Click another button and change maxValue to 0. Updates slider and ticks incorrectly, shows previous ticks.
  5. You can see the same bug here: https://material.angular.io/components/slider/examples

Expected Behavior

Updating slider and ticks correctly.

Actual Behavior

Updated slider and ticks incorrectly.

Environment

  • Angular: 10.2.0
  • CDK/Material: 11.0.2
  • Browser(s): Chome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10 x64

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lukonikcommented, Dec 28, 2021

@DMezhenskyi PLZ Let me know, if you are still going to work on this issue and I’ll close my PR 😃

Hi @lukonik! If this fix is urgent then I do not mind if your solution eventually will be merged. My fix is ready, however, I can deliver my PR in about 3 weeks when I get back from vacation.

P.s from what I remember in my solution, besides the case you covered in your PR, there is also a method _updateTickIntervalPercent where happens division by zero if min and max values are the same. If it happens, the result of the calculation will be “Infinity” which is not a valid CSS value for the tick’s background-size property, so it is also a cause of wrongly repainted ticks.

Hey, thx for your reply. it’s not urgent at all, for me at least 😃. I’ll close my PR then and feel free to push your one .

1reaction
jelbourncommented, Dec 9, 2021

@DMezhenskyi Feel free to send a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

mat-slider: not updating immediately on drag - Stack Overflow
but for some reason, when dragging the slider handle, it does not move to its new position until the mouse is released, which...
Read more >
NG0100: Expression has changed after it was checked - Angular
Angular throws an ExpressionChangedAfterItHasBeenCheckedError when an expression value has been changed after change detection has completed.
Read more >
@material/slider - npm
This is an example of a range slider with internal values of [min, max] = [0, 100] and [start, end] = [30, 70]...
Read more >
Angular Material Slider - YouTube
Step by step beginner's tutorial on how to use Angular Material Slider. This component is used to allow the user to select a...
Read more >
CHANGELOG_ARCHIVE.md - components - Fossies
6.0.0-rc.5 (2018-04-13). Bug Fixes. schematics: move ng-update under correct location (d98fb35). 6.0.0- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found