Skip to content

Commit

Permalink
fix: tipFormatter should not crash with undefined value (#1053)
Browse files Browse the repository at this point in the history
* fix: tipFormatter should not crash with undefined value

* fix

* fix: tacks crash

* Update tests/Slider.test.js

---------

Co-authored-by: afc163 <afc163@gmail.com>
  • Loading branch information
thinkasany and afc163 authored Dec 31, 2024
1 parent 29c1850 commit 678403c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tracks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Tracks: React.FC<TrackProps> = (props) => {

// ========================== Render ==========================
const tracksNode =
classNames.tracks || styles.tracks ? (
trackList?.length && (classNames.tracks || styles.tracks) ? (
<Track
index={null}
prefixCls={prefixCls}
Expand Down
6 changes: 6 additions & 0 deletions tests/Slider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,10 @@ describe('Slider', () => {
const { asFragment } = render(<Slider included={false} />);
expect(asFragment().firstChild).toMatchSnapshot();
});

it('tipFormatter should not crash with undefined value', () => {
[undefined, null].forEach((value) => {
render(<Slider value={value} tooltip={{ open: true }} styles={{ tracks: {} }}/>);
});
});
});

0 comments on commit 678403c

Please sign in to comment.