Skip to content

Build your personal knowledge base with Trilium Notes

feat(views/table): add option to clear sorting

Elian Doran7acd30016389
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 db877f7db4..e7258aa032 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
@@ -15,7 +15,10 @@ export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) {
function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator: Tabulator) {
const e = _e as MouseEvent;
const { title, field } = column.getDefinition();
- const sorter = tabulator.getSorters().find(sorter => sorter.field === field);
+
+ const sorters = tabulator.getSorters();
+ const sorter = sorters.find(sorter => sorter.field === field);
+
contextMenu.show({
items: [
{
@@ -56,6 +59,11 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
])
}
]
+ },
+ {
+ title: "Clear sorting",
+ enabled: sorters.length > 0,
+ handler: () => tabulator.clearSort()
}
],
selectMenuItemHandler() {},