diff --git a/src/components/TagInput.tsx b/src/components/TagInput.tsx index c2291547..417ebdd9 100644 --- a/src/components/TagInput.tsx +++ b/src/components/TagInput.tsx @@ -56,7 +56,8 @@ export default function TagInput({ : option, ] .filter(Boolean) - .map(option => option.toLocaleLowerCase().trim()).join(',')); + .map(parameterize) + .join(',')); setSelectedOptionIndex(undefined); } }, [onChange, selectedOptions]); @@ -110,7 +111,9 @@ export default function TagInput({ break; case 'ArrowDown': setSelectedOptionIndex(i => { - if (i === undefined || i >= optionsFiltered.length - 1) { + if (i === undefined) { + return 1; + } else if (i >= optionsFiltered.length - 1) { return 0; } else { return i + 1; @@ -120,7 +123,8 @@ export default function TagInput({ case 'ArrowUp': setSelectedOptionIndex(i => { if (i === undefined || i === 0) { - return optionsFiltered.length - 1; + inputRef.current?.focus(); + return undefined; } else { return i - 1; } @@ -162,7 +166,8 @@ export default function TagInput({ >
@@ -187,9 +192,10 @@ export default function TagInput({ ref={inputRef} type="text" className={clsx( - 'grow !min-w-0 !p-0 text-lg', + 'grow !min-w-0 !p-0 -my-2 text-xl', '!border-none !ring-transparent', )} + size={12} value={inputText} onChange={e => setInputText(e.target.value)} autoComplete="off" @@ -198,39 +204,40 @@ export default function TagInput({ />
-
- {hasFocus && optionsFiltered.length > 0 && -
- {optionsFiltered.map((option, index) => -
{ - addOption(option); - inputRef.current?.focus(); - setInputText(''); - }} - > - {option} -
)} -
} +
+
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', + 'flex flex-col gap-y-1', + 'text-xl shadow-lg dark:shadow-xl', + )} + > + {optionsFiltered.map((option, index) => +
{ + addOption(option); + inputRef.current?.focus(); + setInputText(''); + }} + > + {option} +
)} +
);