From 8c848a4cb589bf6d0fcbb0741e819674a9a27a23 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 4 Feb 2026 14:04:47 +0200 Subject: [PATCH] fix(mobile): wrong context activation logic when creating new split --- apps/client/src/stylesheets/style.css | 4 ++-- .../widgets/mobile_widgets/mobile_detail_menu.tsx | 12 ++++++++++-- apps/client/src/widgets/ribbon/NoteActions.tsx | 11 ++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css index 90adc404f..e94249741 100644 --- a/apps/client/src/stylesheets/style.css +++ b/apps/client/src/stylesheets/style.css @@ -2639,10 +2639,10 @@ iframe.print-iframe { } } - /* #root-widget.virtual-keyboard-opened .note-split:not(:focus-within) { + #root-widget.virtual-keyboard-opened .note-split:not(.active) { max-height: 80px; opacity: 0.4; - } */ + } } } diff --git a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx index dc0c5e89c..358a61ffc 100644 --- a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx +++ b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx @@ -1,4 +1,5 @@ -import { createPortal, useState } from "preact/compat"; +import { Dropdown as BootstrapDropdown } from "bootstrap"; +import { createPortal, useRef, useState } from "preact/compat"; import FNote, { NotePathRecord } from "../../entities/fnote"; import { t } from "../../services/i18n"; @@ -13,6 +14,7 @@ import NoteActionsCustom from "../ribbon/NoteActionsCustom"; import { NotePathsWidget, useSortedNotePaths } from "../ribbon/NotePathsTab"; export default function MobileDetailMenu() { + const dropdownRef = useRef(null); const { note, noteContext, parentComponent, ntxId, viewScope, hoistedNoteId } = useNoteContext(); const subContexts = noteContext?.getMainContext().getSubContexts() ?? []; const isMainContext = noteContext?.isMainContext(); @@ -32,6 +34,7 @@ export default function MobileDetailMenu() {
{note ? (
@@ -60,7 +63,12 @@ export default function MobileDetailMenu() { {subContexts.length < 2 && <> parentComponent.triggerCommand("openNewNoteSplit", { ntxId })} + onClick={(e) => { + // We have to manually manage the hide because otherwise the old note context gets activated. + e.stopPropagation(); + dropdownRef.current?.hide(); + parentComponent.triggerCommand("openNewNoteSplit", { ntxId }); + }} icon="bx bx-dock-right" >{t("create_pane_button.create_new_split")} } diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx index 51788085d..daeab278c 100644 --- a/apps/client/src/widgets/ribbon/NoteActions.tsx +++ b/apps/client/src/widgets/ribbon/NoteActions.tsx @@ -22,7 +22,7 @@ import MovePaneButton from "../buttons/move_pane_button"; import ActionButton from "../react/ActionButton"; import Dropdown from "../react/Dropdown"; import { FormDropdownDivider, FormDropdownSubmenu, FormListHeader, FormListItem, FormListToggleableItem } from "../react/FormList"; -import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useTriliumEvent, useTriliumOption } from "../react/hooks"; +import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useSyncedRef, useTriliumEvent, useTriliumOption } from "../react/hooks"; import { ParentComponent } from "../react/react_utils"; import { NoteTypeDropdownContent, useNoteBookmarkState, useShareState } from "./BasicPropertiesTab"; import NoteActionsCustom from "./NoteActionsCustom"; @@ -63,8 +63,13 @@ function RevisionsButton({ note }: { note: FNote }) { type ItemToFocus = "basic-properties"; -export function NoteContextMenu({ note, noteContext, extraItems }: { note: FNote, noteContext?: NoteContext, extraItems?: ComponentChildren; }) { - const dropdownRef = useRef(null); +export function NoteContextMenu({ note, noteContext, extraItems, dropdownRef: externalDropdownRef }: { + note: FNote, + noteContext?: NoteContext, + extraItems?: ComponentChildren; + dropdownRef?: RefObject; +}) { + const dropdownRef = useSyncedRef(externalDropdownRef, null); const parentComponent = useContext(ParentComponent); const noteType = useNoteProperty(note, "type") ?? ""; const [viewType] = useNoteLabel(note, "viewType");