Skip to content

Commit

Permalink
Allow Range prop step to be null in Typescript (#757)
Browse files Browse the repository at this point in the history
This is the same like #691 where it was fixed for `Slider` but `Range` seems to have been forgotten. Fixes #739 #652 #574
  • Loading branch information
jnachtigall authored Mar 25, 2021
1 parent b959281 commit 683a818
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import classNames from 'classnames';
import Track from './common/Track';
import createSlider from './common/createSlider';
import * as utils from './utils';
import { SliderProps } from './Slider';
import { GenericSliderProps, GenericSliderState } from './interface';
import type { SliderProps } from './Slider';
import type { GenericSliderProps, GenericSliderState } from './interface';

const trimAlignValue = ({
value,
Expand Down Expand Up @@ -46,7 +46,7 @@ export interface RangeProps extends GenericSliderProps {
reverse?: boolean;
vertical?: boolean;
marks?: Record<number, React.ReactNode | { style?: React.CSSProperties; label?: string }>;
step?: number;
step?: number | null;
threshold?: number;
prefixCls?: string;
included?: boolean;
Expand Down Expand Up @@ -182,8 +182,8 @@ class Range extends React.Component<RangeProps, RangeState> {
return;
}
const currentValue = value || prevState.bounds;
if (currentValue.some(v => utils.isValueOutOfRange(v, this.props))) {
const newValues = currentValue.map(v => utils.ensureValueInRange(v, this.props));
if (currentValue.some((v) => utils.isValueOutOfRange(v, this.props))) {
const newValues = currentValue.map((v) => utils.ensureValueInRange(v, this.props));
onChange(newValues);
}
}
Expand All @@ -196,7 +196,7 @@ class Range extends React.Component<RangeProps, RangeState> {
} else {
const controlledState = {};

['handle', 'recent'].forEach(item => {
['handle', 'recent'].forEach((item) => {
if (state[item] !== undefined) {
controlledState[item] = state[item];
}
Expand Down Expand Up @@ -277,10 +277,10 @@ class Range extends React.Component<RangeProps, RangeState> {
const max = maxValue - Math.max(...startBounds);
const min = minValue - Math.min(...startBounds);
const ratio = Math.min(Math.max(pos / (this.getSliderLength() / 100), min), max);
const nextBounds = startBounds.map(v =>
const nextBounds = startBounds.map((v) =>
Math.floor(Math.max(Math.min(v + ratio, maxValue), minValue)),
);
if (state.bounds.map((c, i) => c === nextBounds[i]).some(c => !c)) {
if (state.bounds.map((c, i) => c === nextBounds[i]).some((c) => !c)) {
this.onChange({
bounds: nextBounds,
});
Expand Down Expand Up @@ -504,7 +504,7 @@ class Range extends React.Component<RangeProps, RangeState> {
ariaValueTextFormatterGroupForHandles,
} = this.props;

const offsets = bounds.map(v => this.calcOffset(v));
const offsets = bounds.map((v) => this.calcOffset(v));

const handleClassName = `${prefixCls}-handle`;
const handles = bounds.map((v, i) => {
Expand All @@ -531,7 +531,7 @@ class Range extends React.Component<RangeProps, RangeState> {
reverse,
disabled,
style: handleStyle[i],
ref: h => this.saveHandle(i, h),
ref: (h) => this.saveHandle(i, h),
ariaLabel: ariaLabelGroupForHandles[i],
ariaLabelledBy: ariaLabelledByGroupForHandles[i],
ariaValueTextFormatter: ariaValueTextFormatterGroupForHandles[i],
Expand Down

1 comment on commit 683a818

@vercel
Copy link

@vercel vercel bot commented on 683a818 Mar 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.