feat: clicking a task now scrolls to and highlights it
selectTask() now also sets in-focus class and calls scrollToTask(), making click behavior consistent with scroll-to-focus behavior. Removed selectedTaskId assignment in loadTasks since selectTask already sets it.
This commit is contained in:
parent
3f0fccd218
commit
fcee783ee5
@ -52,7 +52,6 @@ async function loadTasks() {
|
|||||||
if (savedTaskExists) {
|
if (savedTaskExists) {
|
||||||
focusTaskId = savedTaskId;
|
focusTaskId = savedTaskId;
|
||||||
scrollToTask(savedTaskId);
|
scrollToTask(savedTaskId);
|
||||||
selectedTaskId = savedTaskId;
|
|
||||||
if (isLandscapeMode()) {
|
if (isLandscapeMode()) {
|
||||||
selectTask(savedTaskId);
|
selectTask(savedTaskId);
|
||||||
}
|
}
|
||||||
@ -69,8 +68,6 @@ async function loadTasks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait one frame so the async scroll event from scrollToTask fires first,
|
|
||||||
// then set in-focus and bind handlers after it has been consumed.
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
if (focusTaskId) {
|
if (focusTaskId) {
|
||||||
document.querySelectorAll(".task-item.in-focus").forEach(el => el.classList.remove("in-focus"));
|
document.querySelectorAll(".task-item.in-focus").forEach(el => el.classList.remove("in-focus"));
|
||||||
@ -232,6 +229,14 @@ function selectTask(taskId) {
|
|||||||
|
|
||||||
if (!task) return;
|
if (!task) return;
|
||||||
|
|
||||||
|
document.querySelectorAll(".task-item.in-focus").forEach(el => el.classList.remove("in-focus"));
|
||||||
|
const taskEl = document.querySelector(`[data-task-id="${taskId}"]`);
|
||||||
|
if (taskEl) {
|
||||||
|
taskEl.classList.add("in-focus");
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollToTask(taskId);
|
||||||
|
|
||||||
document.getElementById("edit-task-title").value = task.title;
|
document.getElementById("edit-task-title").value = task.title;
|
||||||
document.getElementById("edit-task-desc").value = task.desc || "";
|
document.getElementById("edit-task-desc").value = task.desc || "";
|
||||||
document.getElementById("side-panel-error").textContent = "";
|
document.getElementById("side-panel-error").textContent = "";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user