fix: prevent scroll position override during page initialization
Add isInitializing flag to block persistSelectedTask during loadTasks, preventing handleScrollFocus from overwriting the saved scroll position
This commit is contained in:
parent
f021395773
commit
27f85cd913
@ -5,6 +5,7 @@ let selectedTaskId = null;
|
||||
let sortableInstance = null;
|
||||
let persistTimer = null;
|
||||
let currentUser = null;
|
||||
let isInitializing = false;
|
||||
|
||||
async function loadGoals() {
|
||||
try {
|
||||
@ -37,6 +38,7 @@ async function loadGoals() {
|
||||
async function loadTasks() {
|
||||
if (!selectedGoalId) return;
|
||||
|
||||
isInitializing = true;
|
||||
try {
|
||||
tasks = await get(`/api/tasks?goal_id=${selectedGoalId}`);
|
||||
|
||||
@ -67,11 +69,13 @@ async function loadTasks() {
|
||||
initScrollFocus();
|
||||
} catch (error) {
|
||||
console.error("Failed to load tasks:", error);
|
||||
} finally {
|
||||
isInitializing = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function persistSelectedTask(taskId) {
|
||||
if (!selectedGoalId) return;
|
||||
if (!selectedGoalId || isInitializing) return;
|
||||
try {
|
||||
await patch(`/api/goals/${selectedGoalId}/selected-task`, { task_id: taskId });
|
||||
const goal = goals.find(g => g.id === selectedGoalId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user