From 0c3365e8f370115aa6f864c060d2f2e8d6b6ea55 Mon Sep 17 00:00:00 2001 From: Maxim Date: Wed, 29 Jan 2025 23:56:34 +0100 Subject: [PATCH] fix: keep search field in Select focused --- src/components/Select/Select.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Select/Select.tsx b/src/components/Select/Select.tsx index e0a50d2..07cf440 100644 --- a/src/components/Select/Select.tsx +++ b/src/components/Select/Select.tsx @@ -98,9 +98,13 @@ export const BoemlySelect: React.FC = ({ useEffect(() => { if (isOpen && isSearchable && inputRef.current) { - inputRef.current.focus(); + requestAnimationFrame(() => { + if (inputRef.current) { + inputRef.current.focus(); + } + }); } - }, [isOpen, isSearchable]); + }, [filteredOptions.length, isOpen, isSearchable]); // Handle selecting an option const handleOptionSelect = useCallback(