I have a similar scenario as described in this question (iOS 8.3 fixed HTML element disappears on input focus) but my issue is different. I have a chatbox iframe within a scrollable parent. When the iframe is open, it expands to fill the entire viewport.
<body>
<!-- PARENT PAGE CONTENT -->
<div class="webchat-container">
<div class="webchat-header-container">blah blah chat</div>
<!-- Iframe contains a reply bar with a text input with fixed positioning to the bottom -->
<iframe src="chatapp"/>
</div>
</body>
The .webchat-container has a set of base mobile styles:
.webchat-container {
width: 100%;
height: 70px;
position: fixed;
bottom: 0;
z-index: 50;
transition: height 300ms ease-in-out;
-webkit-transform: translate3d(0px,0px,0px);
transform: translate3d(0px,0px,0px);
}
When open, .webchat-container gets this additional style:
.webchat-container.open {
height: 100%;
}
On focus of the text input in the reply bar, the child iframe uses postMessage() to let the parent know the input has focus, so can I apply some classes specifically for ios devices to deal with the unfortunate way ios handles fixed positioning.
I add a .no-scroll class to the body of the parent:
body.no-scroll {
position: fixed !important;
top: 0;
bottom: 0;
}
and a class to the responsive container that holds the iframe:
.webchat-container.ios-positioning.open {
position: absolute !important;
overflow: hidden;
top: 0 !important;
bottom: 0 !important;
}
There is a flicker when the input is focused, but other than that, this achieves the desired effect... The softkeyboard slides up and the reply bar is sitting where it should be, just above the keyboard. The chat widget also still correctly fills 100% of the viewport, with no sight of the parent or weird zooming or centering bugs.
And now for the issue....
If I click done to dismiss the keyboard and then focus the input again, the .webchat-container will sometimes become invisible, with only the flashing cursor visible (which is how I know the element is still there and in the correct position). If I inspect the element in Safari, the blue highlighting of the element also shows that it is in the correct place, but just invisible/transparent. The classes are also being applied to and removed from the element correctly.
I have tried dismissing and refocusing the keyboard slowly, fast, irregularly, and sometimes it will repaint correctly and sometimes it wont. It appears to be random. I have also tried forcing repaints by triggering an animation on focus... doesn't work. So I don't even know if this is a lazy repaint issue or not.
The chat app contained within the iframe is React on the front-end and C# & asp.net on the back-end.
If anyone has any idea what could be causing this intermittent element invisibility, and even better, any idea on how to approach solving this, I'd really appreciate it. IOS and its various eccentricities have had pulling my hair out for days, and this is the final problem that I haven't yet been able to solve.