From b45355c951c17749b02c1508874501a4af1d63b8 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sun, 4 Feb 2024 18:38:39 -0600 Subject: [PATCH] Fix input tag auto-focus behavior --- src/components/TagInput.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/TagInput.tsx b/src/components/TagInput.tsx index ce0b4201..f3f34039 100644 --- a/src/components/TagInput.tsx +++ b/src/components/TagInput.tsx @@ -77,12 +77,10 @@ export default function TagInput({ // Focus option in the DOM when selected index changes useEffect(() => { - const options = optionsRef.current?.querySelectorAll('div'); if (selectedOptionIndex !== undefined) { + const options = optionsRef.current?.querySelectorAll('div'); const option = options?.[selectedOptionIndex] as HTMLElement | undefined; option?.focus(); - } else { - inputRef.current?.focus(); } }, [selectedOptionIndex]); @@ -216,7 +214,7 @@ export default function TagInput({ className={clsx( !(hasFocus && optionsFiltered.length > 0) && 'hidden', 'control absolute top-0 mt-4 w-full z-10 !px-1.5 !py-1.5', - 'max-h-[7.5rem] overflow-y-auto', + 'max-h-[8rem] overflow-y-auto', 'flex flex-col gap-y-1', 'text-xl shadow-lg dark:shadow-xl', )}