From 68beb0d41904cdbf55959869428a293e17e9ce76 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Sep 2025 16:52:21 +0300 Subject: [PATCH] feat(collections/table): disable "Insert row above/below" if sorting --- apps/client/src/widgets/collections/table/context_menu.ts | 3 +++ apps/client/src/widgets/collections/table/index.tsx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/client/src/widgets/collections/table/context_menu.ts b/apps/client/src/widgets/collections/table/context_menu.ts index 37caf1663..16cbd39ff 100644 --- a/apps/client/src/widgets/collections/table/context_menu.ts +++ b/apps/client/src/widgets/collections/table/context_menu.ts @@ -160,6 +160,7 @@ function showHeaderContextMenu(parentComponent: Component, e: MouseEvent, tabula export function showRowContextMenu(parentComponent: Component, e: MouseEvent, row: RowComponent, parentNote: FNote, tabulator: Tabulator) { const rowData = row.getData() as TableData; + const sorters = tabulator.getSorters(); let parentNoteId: string = parentNote.noteId; @@ -177,6 +178,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro { title: t("table_view.row-insert-above"), uiIcon: "bx bx-horizontal-left bx-rotate-90", + enabled: !sorters.length, handler: () => parentComponent?.triggerCommand("addNewRow", { parentNotePath: parentNoteId, customOpts: { @@ -203,6 +205,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro { title: t("table_view.row-insert-below"), uiIcon: "bx bx-horizontal-left bx-rotate-270", + enabled: !sorters.length, handler: () => parentComponent?.triggerCommand("addNewRow", { parentNotePath: parentNoteId, customOpts: { diff --git a/apps/client/src/widgets/collections/table/index.tsx b/apps/client/src/widgets/collections/table/index.tsx index 0c4e3e8f8..40f5310c6 100644 --- a/apps/client/src/widgets/collections/table/index.tsx +++ b/apps/client/src/widgets/collections/table/index.tsx @@ -2,7 +2,7 @@ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "p import { ViewModeProps } from "../interface"; import { buildColumnDefinitions } from "./columns"; import getAttributeDefinitionInformation, { buildRowDefinitions, TableData } from "./rows"; -import { useLegacyWidget, useNoteLabel, useNoteLabelBoolean, useNoteLabelInt, useSpacedUpdate, useTriliumEvent } from "../../react/hooks"; +import { useLegacyWidget, useNoteLabelBoolean, useNoteLabelInt, useSpacedUpdate, useTriliumEvent } from "../../react/hooks"; import Tabulator from "./tabulator"; import { Tabulator as VanillaTabulator, SortModule, FormatModule, InteractionModule, EditModule, ResizeColumnsModule, FrozenColumnsModule, PersistenceModule, MoveColumnsModule, MoveRowsModule, ColumnDefinition, DataTreeModule, Options, RowComponent} from 'tabulator-tables'; import { useContextMenu } from "./context_menu";