mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 23:17:09 +00:00
input hot fix
This commit is contained in:
@@ -81,24 +81,16 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadSolutionContent = async () => {
|
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;
|
if (!displayedSolution || !displayedSolution.content) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Only load content for the appropriate task type
|
|
||||||
if (task.type === TaskType.FILE) {
|
if (task.type === TaskType.FILE) {
|
||||||
// For file tasks, we just set the URL - don't touch the answer field
|
setAnswer("");
|
||||||
setSelectedFile(null);
|
setSelectedFile(null);
|
||||||
setSelectedSolutionUrl(displayedSolution.content);
|
setSelectedSolutionUrl(displayedSolution.content);
|
||||||
} else if (task.type === TaskType.CODE || task.type === TaskType.INPUT) {
|
} else {
|
||||||
// For non-file tasks, fetch and set the answer text - don't touch file fields
|
setSelectedFile(null);
|
||||||
|
setSelectedSolutionUrl(null);
|
||||||
const response = await fetch(displayedSolution.content);
|
const response = await fetch(displayedSolution.content);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to fetch solution content: ${response.status}`);
|
throw new Error(`Failed to fetch solution content: ${response.status}`);
|
||||||
@@ -112,7 +104,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
loadSolutionContent();
|
loadSolutionContent();
|
||||||
}, [displayedSolution, task.id, task.type, setAnswer, setSelectedFile]);
|
}, [displayedSolution, task.type, setAnswer, setSelectedFile]);
|
||||||
|
|
||||||
const handleOpenHistory = () => {
|
const handleOpenHistory = () => {
|
||||||
setIsHistoryOpen(true);
|
setIsHistoryOpen(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user