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(mobile): let phone dialogs inside a note be tapped
Elian Doran000620318cf8
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex ae1cfe9ff2..43ba39e3ae 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -1891,12 +1891,16 @@ pre.code-embed-editor.read-only .cm-activeLine {width: 100%;transition: transform 250ms ease-in-out;background: var(--main-background-color);- z-index: 0;++ &:not(.show, .dragging) {+ visibility: hidden;+ transition: transform 250ms ease-in-out, visibility 0s 250ms;+ }}#detail-container {+ position: relative;width: 100%;- z-index: 1;background: var(--main-background-color);transition: transform 250ms ease-in-out;diff --git a/apps/client/src/widgets/mobile_widgets/sidebar_container.spec.ts b/apps/client/src/widgets/mobile_widgets/sidebar_container.spec.tsindex 336c9546ff..a427a55842 100644--- a/apps/client/src/widgets/mobile_widgets/sidebar_container.spec.ts+++ b/apps/client/src/widgets/mobile_widgets/sidebar_container.spec.ts@@ -77,7 +77,9 @@ describe("SidebarContainer", () => {document.body.innerHTML = "";});- it("slides the note off the tree, which lies under it", () => {+ // A transform on the note makes it a stacking context, which traps a dialog the note renders+ // under Bootstrap's backdrop.+ it("slides the note off the tree, which lies under it, and leaves no transform on it at rest", () => {const sidebar = render(true);sidebar.activeScreenChangedEvent({ activeScreen: "tree" });@@ -85,10 +87,24 @@ describe("SidebarContainer", () => {expect(tree.style.transform).toBe("translateX(0%)");sidebar.activeScreenChangedEvent({ activeScreen: "detail" });- expect(detail.style.transform).toBe("translateX(0%)");+ expect(detail.style.transform).toBe("");expect(tree.style.transform).toBe("translateX(-30%)");});+ it("marks the tree as dragged while a swipe from the edge reveals it", () => {+ render(true);+ const touch = (type: string, clientX: number) => document.dispatchEvent(+ Object.assign(new Event(type, { cancelable: true }), { touches: [ { clientX } ] }));++ touch("touchstart", 5);+ touch("touchmove", 40);+ expect(tree.classList.contains("dragging")).toBe(true);++ touch("touchmove", 80);+ touch("touchend", 80);+ expect(tree.classList.contains("dragging")).toBe(false);+ });+it("goes back from the note to the tree on the system back, and not from the tree", () => {const sidebar = render(true);const triggerCommand = vi.spyOn(sidebar, "triggerCommand").mockImplementation(() => undefined);diff --git a/apps/client/src/widgets/mobile_widgets/sidebar_container.ts b/apps/client/src/widgets/mobile_widgets/sidebar_container.tsindex 6f2fff7c01..2c116ab5d6 100644--- a/apps/client/src/widgets/mobile_widgets/sidebar_container.ts+++ b/apps/client/src/widgets/mobile_widgets/sidebar_container.ts@@ -104,6 +104,7 @@ export default class SidebarContainer extends FlexContainer<BasicWidget> {if (deltaX > DRAG_START_THRESHOLD) {/* Disable the transitions since they affect performance, they are going to reenabled once drag ends. */this.sidebarEl.style.transition = "none";+ this.sidebarEl.classList.add("dragging");if (this.detailEl) this.detailEl.style.transition = "none";this.dragState = DRAG_STATE_DRAGGING;@@ -129,6 +130,8 @@ export default class SidebarContainer extends FlexContainer<BasicWidget> {return;}+ this.sidebarEl.classList.remove("dragging");+// Snap the tree open only if the user swiped over a threshold.const isOpen = this.translatePercentage > -(100 - DRAG_OPEN_THRESHOLD);const screen = isOpen ? "tree" : "detail";@@ -176,7 +179,9 @@ export default class SidebarContainer extends FlexContainer<BasicWidget> {const direction = glob.isRtl ? -1 : 1;const openness = 100 + translatePercentage;this.sidebarEl.style.transform = `translateX(${-direction * STACK_PARALLAX * (100 - openness) / 100}%)`;- if (this.detailEl) this.detailEl.style.transform = `translateX(${direction * openness}%)`;+ // At rest the note carries no transform: one makes it a stacking context, which keeps a+ // dialog it renders under Bootstrap's backdrop.+ if (this.detailEl) this.detailEl.style.transform = openness ? `translateX(${direction * openness}%)` : "";}#setSidebarOpen(isOpen: boolean) {