From 7743db8614e13ce1408ea47205dc74a2847803c5 Mon Sep 17 00:00:00 2001 From: coderwelsch Date: Tue, 7 Nov 2023 10:23:17 +0100 Subject: [PATCH] added useCallback because usage of autoSelect --- .../form-field/search-input/search-input.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/form-field/search-input/search-input.tsx b/src/components/form-field/search-input/search-input.tsx index c31fa5d9..e56d51b8 100644 --- a/src/components/form-field/search-input/search-input.tsx +++ b/src/components/form-field/search-input/search-input.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useRef } from "react"; +import React, { useCallback, useRef } from "react"; import { classNames } from "../../../util/class-names"; import CrossIcon from "../../../icons/cross-icon"; import SearchIcon from "../../../icons/search-icon"; @@ -24,15 +24,11 @@ export const SearchInput = ({ const inputRef = useRef(null); const isClearIconShown = !readOnly && !disabled && value !== undefined && value !== ""; - const isClearIconShown = useMemo(() => { - return !readOnly && !disabled && value?.toString().length; - }, [disabled, readOnly, value]); - - const handleAutoSelection = () => { + const handleAutoSelection = useCallback(() => { if (autoSelect && inputRef.current) { inputRef.current.select(); } - }; + }, [autoSelect]); return (