fix: ensure scroll position is restored before initializing scroll focus

Move initScrollFocus() after scrollToTask() to prevent handleScrollFocus()
from incorrectly updating selected_task_id before the saved position is restored
This commit is contained in:
Yuyao Huang 2026-05-09 13:59:57 +08:00
parent b69065e487
commit f021395773

View File

@ -42,7 +42,6 @@ async function loadTasks() {
renderTasks(); renderTasks();
initSortable(); initSortable();
initScrollFocus();
const currentGoal = goals.find(g => g.id === selectedGoalId); const currentGoal = goals.find(g => g.id === selectedGoalId);
const savedTaskId = currentGoal ? currentGoal.selected_task_id : null; const savedTaskId = currentGoal ? currentGoal.selected_task_id : null;
@ -64,6 +63,8 @@ async function loadTasks() {
selectTask(tasks[0].id); selectTask(tasks[0].id);
} }
} }
initScrollFocus();
} catch (error) { } catch (error) {
console.error("Failed to load tasks:", error); console.error("Failed to load tasks:", error);
} }