Skip to content

Conversation

@ali-idrizi
Copy link
Contributor

@ali-idrizi ali-idrizi commented Oct 3, 2025

Before

In the useViewportSize hook, nothing is updating the size state after hydration is run. This was causing useViewport size to get stuck on 0x0 until the window is resized, just like in the screen recording below:

fix-use-viewport.mp4

After

The onResize function is run within the useEffect just as the resize listener is attached. I have written a test that fails without this call.

✅ 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:

@ali-idrizi
Copy link
Contributor Author

Given that onResize has a condition, and the update within useEffect should run unconditionally, I have extract the logic that updates the size state to a separate function, which now gets called instead.

@reidbarber reidbarber added this pull request to the merge queue Jan 7, 2026
Merged via the queue into adobe:main with commit 808343c Jan 7, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants