From ea6299a3c2da2a8cb8c9d9ef75b4efc72b4c1d2e Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Sun, 13 Oct 2024 16:46:56 -0500 Subject: [PATCH] Prevent default on topic change course form --- src/components/forms/course/CourseForm.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/forms/course/CourseForm.js b/src/components/forms/course/CourseForm.js index 3001636..ecbbc9d 100644 --- a/src/components/forms/course/CourseForm.js +++ b/src/components/forms/course/CourseForm.js @@ -122,11 +122,13 @@ const CourseForm = ({ draft = null }) => { } }; - const addTopic = () => { + const addTopic = (e) => { + e.preventDefault(); setTopics([...topics, '']); }; - const removeTopic = (index) => { + const removeTopic = (e, index) => { + e.preventDefault(); const updatedTopics = topics.filter((_, i) => i !== index); setTopics(updatedTopics); }; @@ -206,11 +208,11 @@ const CourseForm = ({ draft = null }) => {
handleTopicChange(index, e.target.value)} placeholder={`Topic #${index + 1}`} className="w-full" /> {index > 0 && ( - removeTopic(index)} /> + removeTopic(e, index)} /> )}
))} - + addTopic(e)} className="p-button-outlined mt-2" />