Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(text): keep the toolbar in place as a menu replaces the keyboard
Elian Doran1bbbba26aca9
diff --git a/apps/client/src/widgets/containers/root_container.spec.ts b/apps/client/src/widgets/containers/root_container.spec.tsindex 8e1f8b370c..71a7a92a88 100644--- a/apps/client/src/widgets/containers/root_container.spec.ts+++ b/apps/client/src/widgets/containers/root_container.spec.ts@@ -1,4 +1,4 @@-import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import LoadResults from "../../services/load_results";import options from "../../services/options";@@ -84,6 +84,25 @@ describe("RootContainer", () => {document.body.style.removeProperty("--tn-keyboard-height");});+ it("measures how far the layout shrinks for the keyboard on Android", () => {+ const $widget = renderInPortrait();+ const layoutHeight = { value: 800 };+ vi.spyOn($widget[0], "getBoundingClientRect").mockImplementation(+ () => ({ height: layoutHeight.value }) as DOMRect);+ const shrink = () => document.body.style.getPropertyValue("--tn-layout-shrink");++ // `interactive-widget=resizes-content` shrinks the window and the layout with the keyboard.+ layoutHeight.value = 450;+ resizeTo({ width: 400, height: 450 });+ expect(shrink()).toBe("350px");++ layoutHeight.value = 800;+ resizeTo({ width: 400, height: 800 });+ expect(shrink()).toBe("0px");+ document.body.style.removeProperty("--tn-layout-shrink");+ document.body.style.removeProperty("--tn-layout-overhang");+ });+it("marks the body while sticky table headers are off, and follows a change", () => {const isMarked = () => document.body.classList.contains("sticky-table-headers-disabled");options.set("textNoteStickyTableHeadersEnabled", "true");diff --git a/apps/client/src/widgets/containers/root_container.ts b/apps/client/src/widgets/containers/root_container.tsindex 54c7038f2d..05263d210c 100644--- a/apps/client/src/widgets/containers/root_container.ts+++ b/apps/client/src/widgets/containers/root_container.ts@@ -67,7 +67,7 @@ export default class RootContainer extends FlexContainer<BasicWidget> {this.#initThemeColor();const $widget = super.render();- if (isIOS() && isMobileApp()) {+ if (isMobile() && (!isIOS() || isMobileApp())) {this.#trackLayoutInsets();}return $widget;@@ -153,8 +153,10 @@ export default class RootContainer extends FlexContainer<BasicWidget> {}/**- * In the iOS app, `Keyboard.resize: "native"` resizes the web view for the keyboard, and the- * layout follows `innerHeight` only some time later. `--tn-layout-shrink` is how much shorter+ * The layout shrinks for the keyboard on Android (`interactive-widget=resizes-content`, or+ * `adjustResize` in the app) and in the iOS app (`Keyboard.resize: "native"`), where it follows+ * `innerHeight` only some time later. Mobile Safari keeps the layout, and+ * `usePositioningOniOS` lifts the toolbar there instead. `--tn-layout-shrink` is how much shorter* than the window the layout is, and `--tn-layout-overhang` how far it reaches below the visible* bottom, so `mobile_editor_toolbar.css` places the toolbar and its menus for the layout as it* stands.