fix(overlays): cap visualViewport width at clientWidth to handle scrollbar gutter#9275
fix(overlays): cap visualViewport width at clientWidth to handle scrollbar gutter#9275hasegawa-101 wants to merge 15 commits intoadobe:mainfrom
Conversation
| // if (width > documentElement.clientWidth) { | ||
| // width = documentElement.clientWidth; | ||
| // } |
There was a problem hiding this comment.
This should probably be rounded to account for sub-pixel differences when zooming.
There was a problem hiding this comment.
shouldn't it be ceil? or floor? I don't quite follow what the concern is here though
also, this doesn't need to be an if, can be
width = Math.min(Math.round(width), documentElement.clientWidth)
There was a problem hiding this comment.
Concern were false-positives in general. I did not take a deeper look at the underlying issue before, but in this case false-positives could result in a tiny gap between the overlay and scrollbar, right? Maybe that's acceptable though - certainly better than cutting content off 🤷
On Firefox & Chrome the clientWidth appears to correspond to Math.round, but Safari apparently uses some other heuristic, neither floor nor ceil.
There was a problem hiding this comment.
This is sounding very similar to some previous iterations of work here https://github.com/adobe/react-spectrum/pull/8958/files#diff-78d190ce0d1388eb141efadb6cae01cfc47f354f8f3bc3a700405d0f74e606b6R24
it's now the weekend for me, I'll try to look again soon.
…utter' into fix/popover-position-scrollbar-gutter
|
Thank you for your patience, we finished up our docs and release today, so I had a little time to look at this. I tried reproducing it with this story in our S2 storybook and was unable to. I assume I couldn't reproduce because the scrollbar wasn't on the I was able to reproduce "something" with this code in our s2-docs inserted after this line However, the fix being suggested in this PR did not fix it. Can you provide a storybook story or docs example to demonstrate the issue and the fix? |
|
|
||
| // If the visual viewport is larger than the client width, it means that the scrollbar gutter is taking up space | ||
| // that the visual viewport is not accounting for. In this case, we should cap the width at the client width. | ||
| width = Math.min(Math.round(width), totalWidth); |
There was a problem hiding this comment.
I think this might not work either. Chrome will return an incorrect document.documentElement.clientWidth value, which includes the scrollbar width, if the document has scrollbar-gutter: stable; but no scrollbar is present.
See also w3c/csswg-drafts#8099 and https://interop-2022-viewport.netlify.app/scrollbar-gutter/short-stable/
|
Comments would indicate this fix is not ready yet. I'm going to close for now. If you wish to keep working on it, please open a new PR with reproduction steps. Thank you! |
Closes #9199
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: