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(slider): correct range operation bug #6674

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

j0rgedev
Copy link
Contributor

Defect Fixes
Fixes #6649

Resolution

Cause
The slider component didn't handle certain range values correctly when the min and max properties were set, particularly when the range included zero and the model value started at zero.

Example:

  • Create a slider with min = -100 and max = 100.
  • Set modelValue = [0, 50].

In this setup:
Values like [1, 50] and [-1, 50] render correctly within the range. However, when the range starts exactly at 0, the slider incorrectly renders to the left instead of between -1 and 1 as expected.
This issue occurred because the slider's position calculation didn't consider cases where the starting value of the range (0) was at the center of the [min, max] boundary.

Solution
I changed the rangeStartPosition and rangeEndPosition logic a little bit:

  • rangeStartPosition now returns 0% when the starting value is below min, which ensures it doesn’t incorrectly render to the left, as mentioned before.
  • rangeEndPosition returns 100% when the end value exceeds max, ensuring the slider fills fully when values are out of bounds.

Extra
I added a couple of unit tests to validate the behavior of the range property within the slider component.

Copy link

vercel bot commented Oct 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Updated (UTC)
primevue ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 0:53am
primevue-v3 ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 0:53am

@tugcekucukoglu tugcekucukoglu merged commit a2eaeba into primefaces:master Nov 12, 2024
2 of 3 checks passed
@j0rgedev j0rgedev deleted the 6649-slider-range-bug branch November 12, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slider range operation bug
2 participants