From 49f900b298ed8fc46a9217b83a550d24c0ebf7ae Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 12 May 2022 11:13:30 -0400 Subject: [PATCH] Tags input: save on enter --- web/components/tags-input.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/components/tags-input.tsx b/web/components/tags-input.tsx index b52d78e9..ff9029c9 100644 --- a/web/components/tags-input.tsx +++ b/web/components/tags-input.tsx @@ -15,9 +15,9 @@ export function TagsInput(props: { contract: Contract; className?: string }) { const [isSubmitting, setIsSubmitting] = useState(false) - const updateTags = () => { + const updateTags = async () => { setIsSubmitting(true) - updateContract(contract.id, { + await updateContract(contract.id, { tags: newTags, lowercaseTags: newTags.map((tag) => tag.toLowerCase()), }) @@ -37,6 +37,12 @@ export function TagsInput(props: { contract: Contract; className?: string }) { disabled={isSubmitting} value={tagText} onChange={(e) => setTagText(e.target.value || '')} + onKeyDown={(e) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault() + updateTags() + } + }} />