FIX: fixed a bug where keyboard on ios was broken (#25338)

It was broken on iOS PWA, when you had the keyboard open and would leave the app. When you came back the body was scrolled and it was looking buggy until you close/reopen keyboard.

This commit attempt to reposition the page correctly 200ms after the tab is visible again.
This commit is contained in:
Joffrey JAFFEUX
2024-01-19 17:07:59 +01:00
committed by GitHub
parent 07a0c6c637
commit a840c295d8
2 changed files with 9 additions and 2 deletions

View File

@ -184,6 +184,7 @@ export default class ChatChannel extends Component {
onPresenceChangeCallback(present) {
if (present) {
this.debouncedUpdateLastReadMessage();
bodyScrollFix({ delayed: true });
}
}

View File

@ -34,7 +34,7 @@ export function stackingContextFix(scrollable, callback) {
}
}
export function bodyScrollFix() {
export function bodyScrollFix(options = {}) {
// when keyboard is visible this will ensure body
// doesn’t scroll out of viewport
if (
@ -42,6 +42,12 @@ export function bodyScrollFix() {
document.documentElement.classList.contains("keyboard-visible") &&
!isZoomed()
) {
document.documentElement.scrollTo(0, 0);
if (options.delayed) {
setTimeout(() => {
document.documentElement.scrollTo(0, 0);
}, 200);
} else {
document.documentElement.scrollTo(0, 0);
}
}
}