fix: restore scroll position and in-focus highlighting correctly
- Set selectedTaskId when loading saved task - Call handleScrollFocus initially to set in-focus class - Skip saving during initialization unless task matches saved
This commit is contained in:
parent
ca7bd7e24e
commit
1df90490e6
@ -57,6 +57,7 @@ async function loadTasks() {
|
||||
if (savedTaskExists) {
|
||||
console.log("loadTasks: using savedTaskId path");
|
||||
scrollToTask(savedTaskId);
|
||||
selectedTaskId = savedTaskId;
|
||||
if (isLandscapeMode()) {
|
||||
selectTask(savedTaskId);
|
||||
}
|
||||
@ -177,6 +178,9 @@ function initScrollFocus() {
|
||||
|
||||
scrollView.removeEventListener("scroll", handleScrollFocus);
|
||||
scrollView.addEventListener("scroll", handleScrollFocus);
|
||||
|
||||
// Initial call to set in-focus class without saving
|
||||
handleScrollFocus();
|
||||
}
|
||||
|
||||
function handleScrollFocus() {
|
||||
@ -207,8 +211,11 @@ function handleScrollFocus() {
|
||||
|
||||
const taskId = parseInt(closestItem.dataset.taskId);
|
||||
|
||||
// Only save during initialization if it matches the saved task
|
||||
if (!isInitializing || taskId === selectedTaskId) {
|
||||
clearTimeout(persistTimer);
|
||||
persistTimer = setTimeout(() => persistSelectedTask(taskId), 400);
|
||||
}
|
||||
|
||||
if (isLandscapeMode()) {
|
||||
if (taskId !== selectedTaskId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user