MCPcopy Create free account
hub / github.com/code100x/cms / addTag

Function addTag

src/components/NewPostDialog.tsx:86–99  ·  view source on GitHub ↗
(event: React.KeyboardEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

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));

Callers

nothing calls this directly

Calls 1

getMethod · 0.65

Tested by

no test coverage detected