Skip to content

Conversation

@lixiaoyan
Copy link
Contributor

@lixiaoyan lixiaoyan commented Dec 22, 2025

This mitigate the #9391 in Modal use cases. This also fixes some edge cases that the visual viewport size may change between the render and the effect.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@lixiaoyan lixiaoyan changed the title fix: re-calculate the visual viewport size in layout effect fix: re-calculate the visual viewport size in the effect Dec 22, 2025
Comment on lines +69 to +70
onResize();

Copy link
Contributor

@nwidynski nwidynski Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of related, I'm wondering whether that is also something we should do in the fallback shim of useResizeObserver. I guess this only applies to the viewport?

if (!hasResizeObserver()) {
window.addEventListener('resize', onResizeEvent, false);
return () => {
window.removeEventListener('resize', onResizeEvent, false);
};
} else {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have an issue open for that here useResizeObserver - not triggered on first render for older browsers
Which we didn't prioritise because it has a workaround.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants