Skip to content

Build your personal knowledge base with Trilium Notes

fix(views/table): context menu remains active while clicking on an expand/collapse button

Elian Doranb255d70e188c
diff --git a/apps/client/src/widgets/view_widgets/table_view/context_menu.ts b/apps/client/src/widgets/view_widgets/table_view/context_menu.ts
index 910c65895d..74f480cb75 100644
--- a/apps/client/src/widgets/view_widgets/table_view/context_menu.ts
+++ b/apps/client/src/widgets/view_widgets/table_view/context_menu.ts
@@ -11,6 +11,13 @@ import type Component from "../../../components/component.js";
export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) {
tabulator.on("rowContext", (e, row) => showRowContextMenu(e, row, parentNote));
tabulator.on("headerContext", (e, col) => showColumnContextMenu(e, col, tabulator));
+
+ // Pressing the expand button prevents bubbling and the context menu remains menu when it shouldn't.
+ if (tabulator.options.dataTree) {
+ const dismissContextMenu = () => contextMenu.hide();
+ tabulator.on("dataTreeRowExpanded", dismissContextMenu);
+ tabulator.on("dataTreeRowCollapsed", dismissContextMenu);
+ }
}
function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator: Tabulator) {