Skip to content

Bug: usePreventScroll does not trigger a resize event on the visual viewportΒ #9391

@lixiaoyan

Description

@lixiaoyan

Provide a general summary of the issue here

When a horizontal scrollable page (a page with a horizontal scrollbar) is prevented from scrolling, a resize event should be triggered on the visual viewport since the horizontal scrollbar is no longer visible. However, with Chrome, the resize event is only triggered after the page scroll is restored.

The real-world example is that we build a drawer component with a height that matches the --visual-viewport-height.

I am not sure if this is a browser issue. It only happens with Chrome.

πŸ€” Expected Behavior?

When a drawer is opened, its height should match the entire window.

😯 Current Behavior

Until another resize event is triggered, the drawer's height is incorrect.

πŸ’ Possible Solution

No response

πŸ”¦ Context

No response

πŸ–₯️ Steps to Reproduce

https://stackblitz.com/edit/rac-visual-viewport-prevent-scroll?file=src%2FApp.tsx,src%2Findex.css

Screen.Recording.2025-12-22.at.4.49.56.PM.mov

Version

1.14.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macOS

🧒 Your Company/Team

No response

πŸ•· Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions