adobe / adobe/react-spectrum

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

Open
#9,391 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### 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

https://github.com/user-attachments/assets/e17e9ab4-ed85-4d8d-9e4e-7c3faa7e17a2

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.