Skip to content

fix(VSlider): correct roundValue when min is not a multiple of step#22780

Closed
hellozzm wants to merge 1 commit intovuetifyjs:masterfrom
hellozzm:fix/issue-22348
Closed

fix(VSlider): correct roundValue when min is not a multiple of step#22780
hellozzm wants to merge 1 commit intovuetifyjs:masterfrom
hellozzm:fix/issue-22348

Conversation

@hellozzm
Copy link
Copy Markdown

Summary

When min is not a multiple of step (e.g., min=0.1, step=1), the roundValue function in useSteps incorrectly computes min % step as an offset, causing floating point rounding errors. For example, a thumb at value 25 would display as 25.1 instead of 25.

The fix computes the number of steps from min and builds the rounded value from there, avoiding the offset-based approach entirely.

Playground Markup

<template>
  <v-app>
    <v-container style="max-width: 400px">
      <p>With bug: thumb should show 25, not 25.1</p>
      <v-slider
        :min="0.1"
        :max="100"
        :step="1"
        thumb-label
        model-value="25"
      ></v-slider>
      
      <p class="mt-4">Another example: min=0.3, step=1, value=10</p>
      <v-slider
        :min="0.3"
        :max="50"
        :step="1"
        thumb-label
        model-value="10"
      ></v-slider>
    </v-container>
  </v-app>
</template>

<script setup>
</script>

Testing

  1. Open the playground above
  2. Check the first slider thumb label - it should show 25 (not 25.1)
  3. Click on the slider and drag - values should snap to integers (0.1, 1.1, 2.1, ... no, to 0, 1, 2...)
  4. Check the second slider - thumb should show 10 (not 10.3)
  5. Before fix: first slider showed 25.1, second showed 10.3

Fixes #22348

When min value is not a multiple of step (e.g., min=0.1, step=1), the
roundValue function incorrectly used min % step as an offset, causing
floating point errors. For example, a thumb value of 25 would display
as 25.1 instead of 25.

Fixed by computing steps relative to min instead of using an offset.

Fixes vuetifyjs#22348
@J-Sek
Copy link
Copy Markdown
Contributor

J-Sek commented Mar 29, 2026

Just stop posting PRs. We don't need this slop.

@J-Sek J-Sek closed this Mar 29, 2026
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.

[Bug Report][3.10.11] The slider thumb incorrectly adds .1 if :min="0.1" and :step="1"

2 participants