From e9b714e78573ff7d67d0e1525184779fbd6ebe23 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 3 Feb 2024 14:03:07 -0600 Subject: [PATCH] Remove last term, tweak check mark --- src/components/CommaSeparatedInput.tsx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/components/CommaSeparatedInput.tsx b/src/components/CommaSeparatedInput.tsx index 752430bf..bab7ee57 100644 --- a/src/components/CommaSeparatedInput.tsx +++ b/src/components/CommaSeparatedInput.tsx @@ -18,9 +18,6 @@ export default function CommaSeparatedInput({ onChange?: (value: string) => void options?: string[] } & Omit, 'onChange'>) { - const lastTerm = value?.split(',').slice(-1)?.[0].trim(); - const hasLastTerm = lastTerm && !optionsRaw.includes(lastTerm); - const items = (convertStringToArray(value) ?? []) .map(tag => tag.trim()) .filter(Boolean); @@ -60,31 +57,29 @@ export default function CommaSeparatedInput({ /> } - {(options || hasLastTerm) && + {options && - {hasLastTerm && - - Create {`"${lastTerm}"`} - } {options.map((tag) => ( clsx( 'p-1 rounded-[0.2rem] !hover:cursor', - focus && 'text-invert bg-invert', + focus && 'bg-gray-100 dark:bg-gray-900', )} > {({ selected }) =>
+ + {selected && + } + {tag} - {selected && - } +
}
))}