();
// Add marks
@@ -23,6 +24,9 @@ export default function Steps(props: StepsProps) {
dotSet.add(mark.value);
});
+ // Set marksValue
+ const uniqueMarksValue = Array.from(dotSet);
+
// Fill dots
if (dots && step !== null) {
let current = min;
@@ -32,20 +36,31 @@ export default function Steps(props: StepsProps) {
}
}
- return Array.from(dotSet);
+ return {
+ marksValue: uniqueMarksValue,
+ stepDots: Array.from(dotSet),
+ };
}, [min, max, step, dots, marks]);
return (
- {stepDots.map((dotValue) => (
-
- ))}
+ {stepDots.map((dotValue) => {
+ // Check whether it is a marks dot
+ const isMarksDot = marksValue.indexOf(dotValue) >= 0;
+
+ return (
+
+ );
+ })}
);
}
diff --git a/tests/marks.test.js b/tests/marks.test.js
index 0d8c53c57..17f2063a5 100644
--- a/tests/marks.test.js
+++ b/tests/marks.test.js
@@ -19,12 +19,14 @@ describe('marks', () => {
const marks = { 0: 0, 30: '30', 99: '', 100: '100' };
const { container } = render();
+ expect(container.getElementsByClassName('rc-slider-marks-dot')).toHaveLength(3);
expect(container.getElementsByClassName('rc-slider-mark-text')).toHaveLength(3);
expect(container.getElementsByClassName('rc-slider-mark-text')[0].innerHTML).toBe('0');
expect(container.getElementsByClassName('rc-slider-mark-text')[1].innerHTML).toBe('30');
expect(container.getElementsByClassName('rc-slider-mark-text')[2].innerHTML).toBe('100');
const { container: container2 } = render();
+ expect(container2.getElementsByClassName('rc-slider-marks-dot')).toHaveLength(3);
expect(container2.getElementsByClassName('rc-slider-mark-text')).toHaveLength(3);
expect(container2.getElementsByClassName('rc-slider-mark-text')[0].innerHTML).toBe('0');
expect(container2.getElementsByClassName('rc-slider-mark-text')[1].innerHTML).toBe('30');