Skip to content

Commit 82cd9ae

Browse files
authored
fix: page crash when dots is true and step is null (#838)
* fix: page crash when dots is true and step is null * test: add test case * test: update test case
1 parent b50dbed commit 82cd9ae

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Steps/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function Steps(props: StepsProps) {
2424
});
2525

2626
// Fill dots
27-
if (dots) {
27+
if (dots && step !== null) {
2828
let current = min;
2929
while (current <= max) {
3030
dotSet.add(current);

tests/common.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ describe('Common', () => {
5151
expect(container2.getElementsByClassName('rc-slider-dot-active')).toHaveLength(4);
5252
});
5353

54+
it('should render normally when `dots=true` and `step=null`', () => {
55+
const { container } = render(<Slider step={null} dots />);
56+
expect(() => container).not.toThrowError();
57+
});
58+
5459
it('should render dots correctly when dotStyle is dynamic`', () => {
5560
const { container: container1 } = render(
5661
<Slider value={50} step={10} dots dotStyle={(dotValue) => ({ width: `${dotValue}px` })} />,

0 commit comments

Comments
 (0)