Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {} }}/>);
Copy link
Member

Choose a reason for hiding this comment

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

为啥要兼容这样的用法?

Copy link
Member

Choose a reason for hiding this comment

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

兼容的是 styles={{ tracks: {} }} 还是 value={null} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个单测是antd搬过来的,兼容的是value={null},在styles.tracks存在时,如果trackList.length不存在的话就会报错。
image

});
});
});