From 757c1d80230bd4a44dcda42c799abcaf67925a15 Mon Sep 17 00:00:00 2001 From: rngsurrounded Date: Mon, 3 Mar 2025 22:16:59 +0900 Subject: [PATCH] input hot fix --- .../modules/TaskSolution/index.tsx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx index 8d4051e..5faf95e 100644 --- a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx +++ b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx @@ -81,24 +81,16 @@ const TaskSolution: React.FC = ({ useEffect(() => { const loadSolutionContent = async () => { - // Clear previous inputs when task changes - if (prevTaskIdRef.current !== task.id) { - setAnswer(""); - setSelectedFile(null); - setSelectedSolutionUrl(null); - prevTaskIdRef.current = task.id; - } - if (!displayedSolution || !displayedSolution.content) return; try { - // Only load content for the appropriate task type if (task.type === TaskType.FILE) { - // For file tasks, we just set the URL - don't touch the answer field + setAnswer(""); setSelectedFile(null); setSelectedSolutionUrl(displayedSolution.content); - } else if (task.type === TaskType.CODE || task.type === TaskType.INPUT) { - // For non-file tasks, fetch and set the answer text - don't touch file fields + } else { + setSelectedFile(null); + setSelectedSolutionUrl(null); const response = await fetch(displayedSolution.content); if (!response.ok) { throw new Error(`Failed to fetch solution content: ${response.status}`); @@ -112,7 +104,7 @@ const TaskSolution: React.FC = ({ }; loadSolutionContent(); - }, [displayedSolution, task.id, task.type, setAnswer, setSelectedFile]); + }, [displayedSolution, task.type, setAnswer, setSelectedFile]); const handleOpenHistory = () => { setIsHistoryOpen(true);