Skip to content

[Slider] Slider doesn't work when step is <= 1e-7 #3852

@eliasmalik

Description

@eliasmalik

Bug report

Current Behavior

When step is <= 1e-7, the slider is non-responsive to dragging the thumbs.

Expected behavior

Slider should work as normal, even for small step values.

Suggested solution

The problem is in getDecimalCount:

function getDecimalCount(value: number) {
return (String(value).split('.')[1] || '').length;
}

This implementation only works for numbers whose JS string representation is decimal. For very small numbers (<= 1e-7), JS changes the string representation to scientific notation (i.e. no decimal places, except maybe in the coefficient).

Your environment

Software Name(s) Version
Radix Package(s) react-slider 1.1.1
React n/a 18
Browser 18.2
Assistive tech
Node n/a 22
npm/yarn/pnpm 11.6.2
Operating System macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions