Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forcing re-layout on hook useViewportOffsetTop #55071

Open
rinej opened this issue Jan 10, 2025 · 2 comments
Open

Forcing re-layout on hook useViewportOffsetTop #55071

rinej opened this issue Jan 10, 2025 · 2 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Reviewing Has a PR in review

Comments

@rinej
Copy link
Contributor

rinej commented Jan 10, 2025

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.

@rinej
Copy link
Contributor Author

rinej commented Jan 10, 2025

I am Tomek from Callstack, I'd like to work on that issue.
Link to the slack conversation and proposal -> https://callstack-hq.slack.com/archives/C05LX9D6E07/p1736336258693379

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 labels Jan 10, 2025
@mountiny mountiny added the Bug Something is broken. Auto assigns a BugZero manager. label Jan 10, 2025
Copy link

melvin-bot bot commented Jan 10, 2025

Triggered auto assignment to @maddylewis (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

4 participants