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