Skip to content

Commit fd30f33

Browse files
committed
Be more judicious about setting a default step for non-integer sliders
1 parent fa0e251 commit fd30f33

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/dash-core-components/src/components/RangeSlider.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ export default function RangeSlider({
1818
persistence_type = PersistenceTypes.local,
1919
// eslint-disable-next-line no-magic-numbers
2020
verticalHeight = 400,
21-
step = 1,
21+
step = undefined,
2222
...props
2323
}: RangeSliderProps) {
24+
// Some considerations for the default value of `step`:
25+
// If the range consists of integers, default to a value of `1`
26+
// Otherwise, leave it undefined
27+
if (Number.isInteger(props.min) && Number.isInteger(props.max)) {
28+
step = 1;
29+
}
30+
2431
return (
2532
<Suspense fallback={null}>
2633
<RealRangeSlider

0 commit comments

Comments
 (0)