requestAnimationFrame waits until after the browser has rendered the current frame, which includes processing the async scroll event queued by scrollToTask. This ensures in-focus is set after the scroll event fires, not overwritten by it.
requestAnimationFrame waits until after the browser has rendered the current frame, which includes processing the async scroll event queued by scrollToTask. This ensures in-focus is set after the scroll event fires, not overwritten by it.