Skip to content

[HOLD for payment 2025-01-22] Forcing re-layout on hook useViewportOffsetTop #55071

Description

@rinej

Background
We use useViewportOffsetTop to properly display keyboard on small device on the mobile browsers

Problem
We noticed that window.scrollTo is being called frequently in useViewportOffsetTop, even when the target scroll position has already been reached. This logic is primarily necessary for small screens when using the app in a browser, but it is triggered unnecessarily on all devices.
Calling window.scrollTo causes redundant style recalculations, which can take up to 13ms.

scrollTo

Solution
We can add an additional check to prevent window.scrollTo from being triggered when the scroll position is already at the target. This optimization will eliminate unnecessary style recalculations and improve overall performance.

Issue OwnerCurrent Issue Owner: @maddylewis

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions