fix: refresh side panel after loadTasks in non-landscape mode
After saveTask or setTaskStatus triggers loadTasks(), the side panel now refreshes from the updated server data. If the selected task no longer exists (deleted or goal changed), the side panel closes. This ensures Edit Task always matches selectedTaskId.
This commit is contained in:
@@ -76,6 +76,22 @@ async function loadTasks() {
|
||||
focusEl.classList.add("in-focus");
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh side panel if a task was selected
|
||||
if (selectedTaskId) {
|
||||
const currentTask = tasks.find(t => t.id === selectedTaskId);
|
||||
if (currentTask) {
|
||||
document.getElementById("edit-task-title").value = currentTask.title;
|
||||
document.getElementById("edit-task-desc").value = currentTask.desc || "";
|
||||
document.querySelectorAll(".status-btn").forEach(btn => {
|
||||
btn.classList.toggle("active", btn.dataset.status === currentTask.status);
|
||||
});
|
||||
updateSaveButton();
|
||||
} else {
|
||||
closeSidePanel();
|
||||
}
|
||||
}
|
||||
|
||||
initScrollFocus();
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user