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 sortableInstance = null;
|
||||||
let persistTimer = null;
|
let persistTimer = null;
|
||||||
let currentUser = null;
|
let currentUser = null;
|
||||||
|
let isInitializing = false;
|
||||||
|
|
||||||
async function loadGoals() {
|
async function loadGoals() {
|
||||||
try {
|
try {
|
||||||
@ -37,6 +38,7 @@ async function loadGoals() {
|
|||||||
async function loadTasks() {
|
async function loadTasks() {
|
||||||
if (!selectedGoalId) return;
|
if (!selectedGoalId) return;
|
||||||
|
|
||||||
|
isInitializing = true;
|
||||||
try {
|
try {
|
||||||
tasks = await get(`/api/tasks?goal_id=${selectedGoalId}`);
|
tasks = await get(`/api/tasks?goal_id=${selectedGoalId}`);
|
||||||
|
|
||||||
@ -67,11 +69,13 @@ async function loadTasks() {
|
|||||||
initScrollFocus();
|
initScrollFocus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to load tasks:", error);
|
console.error("Failed to load tasks:", error);
|
||||||
|
} finally {
|
||||||
|
isInitializing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function persistSelectedTask(taskId) {
|
async function persistSelectedTask(taskId) {
|
||||||
if (!selectedGoalId) return;
|
if (!selectedGoalId || isInitializing) return;
|
||||||
try {
|
try {
|
||||||
await patch(`/api/goals/${selectedGoalId}/selected-task`, { task_id: taskId });
|
await patch(`/api/goals/${selectedGoalId}/selected-task`, { task_id: taskId });
|
||||||
const goal = goals.find(g => g.id === selectedGoalId);
|
const goal = goals.find(g => g.id === selectedGoalId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user