Encountering a challenge while developing a chat input that needed to stay fixed at the bottom of the page, I faced an issue with the iOS keyboard overlapping the input field. Determining the exact height of the keyboard proved to be quite tricky. In my quest for a reliable value to use for positioning the chat input container above the keyboard, I sought to find the current "innerHeight" value, representing the visible area of the webpage. Due to the behavior of the iOS keyboard, it seemed that the only way to obtain this value with the keyboard open was by scrolling to the very bottom of the page and taking a sample of "window.innerHeight".
To tackle this problem, I set up an event listener on the input field triggered by a 'click' event (as using 'focus' caused issues). This action opened the keyboard, which took some time. Therefore, I implemented a timeout of 1000ms to ensure that the keyboard was fully open. After the timeout, I scrolled quickly to the bottom of the page using JavaScript, recorded the value of "window.innerHeight" in that state, and then returned to my original position. This method allowed me to capture the actual height of the visible screen area.
It appeared that the browser window remained placed behind the keyboard until reaching the bottom, at which point the whole window would 'scroll up', aligning the bottom with the top of the keyboard view.
With the obtained value, I calculated where to position the chat input by adding the currently scrolled value (window.scrollY) with the saved value and subtracting the height of my absolutely positioned element. To prevent flickering during scrolling, I also chose to hide the input field. One drawback of this approach was a quick flicker of the page when measuring at the bottom.
I encountered difficulty in determining the variable height of the address bar but opted to make the input slightly taller than necessary to accommodate any potential padding required.