fix(mobile): virtual keyboard detection not working on Android

This commit is contained in:
Elian Doran 2026-02-25 18:35:01 +02:00
parent df4fa42acd
commit ae9827c436
No known key found for this signature in database
2 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,6 @@
import "./NoteDetail.css";
import clsx from "clsx";
import { note } from "mermaid/dist/rendering-util/rendering-elements/shapes/note.js";
import { isValidElement, VNode } from "preact";
import { useEffect, useRef, useState } from "preact/hooks";

View File

@ -19,9 +19,12 @@ import FlexContainer from "./flex_container.js";
*/
export default class RootContainer extends FlexContainer<BasicWidget> {
private originalWindowHeight: number;
constructor(isHorizontalLayout: boolean) {
super(isHorizontalLayout ? "column" : "row");
this.originalWindowHeight = window.innerHeight ?? 0;
this.id("root-widget");
this.css("height", "100dvh");
}
@ -65,7 +68,7 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
#onMobileResize() {
const viewportHeight = window.visualViewport?.height ?? window.innerHeight;
const windowHeight = window.innerHeight;
const windowHeight = Math.max(window.innerHeight, this.originalWindowHeight); // inner height changes when keyboard is opened, we need to compare with the original height to detect it.
// If viewport is significantly smaller, keyboard is likely open
const isKeyboardOpened = windowHeight - viewportHeight > 150;