Skip to content

Commit

Permalink
added useCallback because usage of autoSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
coderwelsch committed Nov 7, 2023
1 parent 2139df7 commit 7743db8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/components/form-field/search-input/search-input.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -24,15 +24,11 @@ export const SearchInput = ({
const inputRef = useRef<HTMLInputElement>(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 (
<div className={classNames("relative w-full")}>
Expand Down

0 comments on commit 7743db8

Please sign in to comment.