(event: React.KeyboardEvent<HTMLInputElement>)
| 84 | }; |
| 85 | |
| 86 | const addTag = (event: React.KeyboardEvent<HTMLInputElement>) => { |
| 87 | if (event.key === ',') { |
| 88 | event.preventDefault(); |
| 89 | const formData = new FormData(formRef.current as HTMLFormElement); |
| 90 | const tag = formData.get('tags')?.toString().trim().replace(/,+$/, ''); |
| 91 | |
| 92 | if (tag) { |
| 93 | setTags((prevTags) => [...prevTags, tag]); |
| 94 | } |
| 95 | if (tagInputRef.current) { |
| 96 | tagInputRef.current.value = ''; |
| 97 | } |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | const removeTag = (tag: string) => { |
| 102 | setTags(tags.filter((t) => t !== tag)); |