-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: only handle blur event for resizing viewport on iOS #9393
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
base: main
Are you sure you want to change the base?
fix: only handle blur event for resizing viewport on iOS #9393
Conversation
Did you notice a discrepancy between browsers with this behaviour and if so, what was it? or is something misbehaving? |
|
The issue is that |
|
The top three PRs (#9393 #9392 #9384) are mostly independent bug fixes that do not rely on any other PRs. Although they were discovered during the last one PR #9318. The last two PRs (#9318 #9383) are attempting to address the same problem - correctly placing a dialog on a page that has been horizontally scrolled - in two different ways. They do not depend on any other PRs either. |
|
Edited: I've updated the PR title/description and updated the commit message to Original post#9393 and #9384 are around the same topic. In the Web world, there are too many metrics about for viewport/page/document/window/... We should choose the fallback carefully, to avoid using any pair that are inconsistent. Back to this PR. It's safe to use However, it does not yet cause any problems, because:
So, yea, this is another correctness fix. I cannot provide a reproducible example with the RAC. It's currently only about this hook. You can check https://stackblitz.com/edit/5qposhdl?file=src%2FExample.tsx for the hook issue. function Example() {
const viewportSize = useViewportSize();
return (
<div>
{JSON.stringify(viewportSize)}
<input />
<div style={{ height: '200vh' }} />
</div>
);
}Screen.Recording.2026-01-07.at.8.30.41.PM.mov |
f73c297 to
272f653
Compare
# Conflicts: # packages/@react-aria/utils/src/useViewportSize.ts

window.innerWidth/HeightandvisualViewport.width/heightare not equivalent. Thewindow.innerWidth/Heightincludes the scrollbar, but thevisualViewport.width/heightdoes not.It's safe to use
window.innerWidth/Heightas fallback values on iOS, because their scrollbar does not take spaces. But for desktop platforms, it's not suitable.However, it does not yet cause any problems in RAC, because:
Modal. We disabled document scroll first, sowindow.innerHeightis always equal tovisualViewport.height. (scrollbar-gutter: stableaffects only the vertical scrollbar)useViewportSize().widthanywhere, therefore the difference betweenwindow.innerWidthandvisualViewport.widthisn't noticeable. 1It currently only affects those who use the hook directly. You can check https://stackblitz.com/edit/5qposhdl?file=src%2FExample.tsx for the issue.
Screen.Recording.2026-01-07.at.8.30.41.PM.mov
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project:
Screen.Recording.2026-01-07.at.9.06.31.PM.mov
Footnotes
The
useViewportSize().widthis incorrect even when used inside aModalwith scroll disabled. See the screen record above that tested on Firefox. (Chrome has another bug that causesvisualViewport.widthto include the scrollbar) ↩