The context
Hi y'all, I have made a full screen web app: it's a whatsapp clone, made for a school project. It's possibile to view the actual project live at this link and the repo is also available at this link.
The Actual Situation
- I have a CSS variable
height: var(--app-height);
that dynamically update when the visualViewport.height
change through a function
export const setAppHeight = () => {
let vh = visualViewport.height;
document.documentElement.style.setProperty(
'--app-height',
`${visualViewport.height}px`,
);
};
that is called all around the code.
The problem
The problem is:
- When in desktop view all work as expected, the app resize itself and nothing else change.
- When I visit the website from an iPhone (or an Android phone), all works perfectly UNTIL I hit one of the two input boxes. Suddenly, the keyboard shows and the app itself resize correctly, filling the space available in the viewport (total visualViewport, on my iPhone nearly 369px with the keyboard open, 642px with the keyboard close), but you can scroll now the page, way too much far from the app itself. I Have colored the html background (red) and the body background (yellow) so you can see all that extra space.
It's three days since I discovered this problem and I have found no solution at all, neither my teacher, my tutor or some friends that already work as developer.
The problem seems related to some strange behaviour of the input box, but just in mobile phones.
Things I tried
Things I've already tried:
- removed the variable
- add event listener on input focus
- ResizeObserver object
- preventDefault() on scrolling when clicking the input tag
What I'm trying to achieve
What I'm trying to achieve:
- When inside the input box the app itself must stay locked to the actual view.
- in the project I'm using a Vue framework, because it's requested.
Anyone have some clever ideas?
Thank you.