Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit b894b3e

Browse files
committed
fixed
1 parent 2fd1d5e commit b894b3e

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/components/DefaultHeader.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ import TagsIcon from "components/img/TagsIcon";
1515
import { AddColumnModal } from "components/modals/newColumn/addColumnModal";
1616
import { InputType, MetadataColumns } from "helpers/Constants";
1717
import { LOGGER } from "services/Logger";
18-
import { DatabaseHeaderProps, RowDataType, TableColumn } from "cdm/FolderModel";
18+
import { DatabaseHeaderProps, TableColumn } from "cdm/FolderModel";
1919
import ReactDOM from "react-dom";
2020
import { c } from "helpers/StylesHelper";
2121
import { RowSelectOption } from "cdm/ComponentsModel";
2222
import { AddColumnModalProps } from "cdm/ModalsModel";
23-
import { AccessorFn, Row } from "@tanstack/react-table";
24-
import { Literal } from "obsidian-dataview";
2523

2624
/**
2725
* Generate column Options with Select type
@@ -103,9 +101,6 @@ export default function DefaultHeader(headerProps: DatabaseHeaderProps) {
103101
propertyIcon = <MarkdownObsidian />;
104102
break;
105103
case InputType.TAGS:
106-
header.column.accessorFn = (originalRow: RowDataType, index: number) => {
107-
return originalRow[id] as Literal;
108-
};
109104
propertyIcon = <TagsIcon />;
110105
break;
111106
case InputType.TASK:

src/components/Table.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { DndProvider } from "react-dnd";
4141
import { HTML5Backend } from "react-dnd-html5-backend";
4242
import TableCell from "components/TableCell";
4343
import getInitialColumnSizing from "components/behavior/InitialColumnSizeRecord";
44+
import { globalDatabaseFilterFn } from "components/reducers/TableFilterFlavours";
4445

4546
const defaultColumn: Partial<ColumnDef<RowDataType>> = {
4647
minSize: DatabaseLimits.MIN_COLUMN_HEIGHT,
@@ -221,7 +222,9 @@ export function Table(tableData: TableDataType) {
221222
setColumnSizing(list);
222223
},
223224
onColumnOrderChange: setColumnOrder,
224-
globalFilterFn: "includesStringSensitive",
225+
// Hack to force react-table to use all columns when filtering
226+
getColumnCanGlobalFilter: (column) => true,
227+
globalFilterFn: globalDatabaseFilterFn(ddbbConfig),
225228
meta: {
226229
tableState: tableStore,
227230
view: view,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { FilterFn, Row } from "@tanstack/react-table"
2+
import { RowDataType } from "cdm/FolderModel"
3+
import { LocalSettings } from "cdm/SettingsModel";
4+
import { InputType } from "helpers/Constants";
5+
import { Literal } from "obsidian-dataview";
6+
import { DataviewService } from "services/DataviewService";
7+
8+
export const globalDatabaseFilterFn: (ddbbConfig: LocalSettings) => FilterFn<RowDataType> = (ddbbConfig: LocalSettings) => (
9+
row: Row<RowDataType>,
10+
columnId: string,
11+
filterValue: string
12+
) => {
13+
const value = row.getValue<Literal>(columnId);
14+
if (value === undefined) {
15+
return false;
16+
}
17+
const sanitized = DataviewService.parseLiteral(value, InputType.MARKDOWN, ddbbConfig, true);
18+
return sanitized.toString().includes(filterValue)
19+
}

0 commit comments

Comments
 (0)