scrollTop assignment triggers an async scroll event. When all tasks fit in the viewport, handleScrollFocus recalculates center-aligned task and picks the last one instead of the saved one. Using setTimeout(0) defers handler binding to after the queued event fires.