Open BeeMargarida opened 1 year ago
I'll try to investigate a fix for this
Not really sure if this is a react-navigation issue or something related to react-native-web. Based on https://developer.chrome.com/blog/url-bar-resizing/, the correct logic is already being applied by setting the height of html
and body
to 100%
. However, #root
does not occupy that whole height.
If anyone has any insight I would greatly appreciate it
Found a fix for it, but perhaps this should reside in react-native-web and not here (will find a place for it and perhaps close this one here).
Instead of using min-height: 100%
, it should set the height taking into consideration the innerHeight of the browser so that it adapts to the address bar collapse. The bug is happening because the document.body.clientHeight
is different that the window.innerHeight
after navigation and with the address bar collapsed.
A fix would be something like the code below:
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
document.body.setAttribute(
'style',
`height: calc(var(--vh, 1vh) * 100);`
);
Current behavior
This behaviour only happens in Chrome mobile, I think it's related to the behaviour of hiding the browser top bar on scroll:
In the reproduction link provided, to test is better to download as a zip, install the dependencies and then run
yarn web
. Example of the problem using the snack provided:https://user-images.githubusercontent.com/25725586/224362468-18b0c49d-15e1-46d8-aed0-a3b9c851d068.mov
Expected behavior
The expected behaviour would be make the screen occupy the whole height of the screen.
Reproduction
https://snack.expo.dev/@daisy112351/448299
Platform
Packages
Environment