From d5b3eac0825d2376c6e274adaade5af552313346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20G=C3=B3mez=20Pinta?= <44321109+GomezIvann@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:29:30 +0100 Subject: [PATCH] Small fix in Slider component --- lib/src/slider/Slider.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/src/slider/Slider.tsx b/lib/src/slider/Slider.tsx index 87f2f119f..1bb3a0cd0 100644 --- a/lib/src/slider/Slider.tsx +++ b/lib/src/slider/Slider.tsx @@ -7,8 +7,6 @@ import useTheme from "../useTheme"; import SliderPropsType, { RefType } from "./types"; import { v4 as uuidv4 } from "uuid"; -const isFirefox = navigator.userAgent.indexOf("Firefox") !== -1; - const DxcSlider = React.forwardRef( ( { @@ -36,6 +34,7 @@ const DxcSlider = React.forwardRef( const [innerValue, setInnerValue] = useState(defaultValue ?? 0); const [dragging, setDragging] = useState(false); const colorsTheme = useTheme(); + const isFirefox = navigator?.userAgent.indexOf("Firefox") !== -1; const minLabel = useMemo( () => (labelFormatCallback ? labelFormatCallback(minValue) : minValue), @@ -48,10 +47,11 @@ const DxcSlider = React.forwardRef( ); const tickMarks = useMemo(() => { - const ticks = []; const numberOfMarks = Math.floor(maxValue / step - minValue / step); - let index = 0; const range = maxValue - minValue; + const ticks = []; + let index = 0; + if (marks) { while (index <= numberOfMarks) { ticks.push( @@ -65,9 +65,7 @@ const DxcSlider = React.forwardRef( index++; } return ticks; - } else { - return null; - } + } else return null; }, [minValue, maxValue, step, value, innerValue]); const handleSliderChange = (event) => { @@ -371,4 +369,4 @@ const StyledTextInput = styled.div` max-width: 70px; `; -export default DxcSlider; +export default DxcSlider; \ No newline at end of file