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

Commit 15b48bc

Browse files
committed
Merge branch '260-search-function-does-not-work-with-tags'
2 parents 03405e1 + b894b3e commit 15b48bc

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

src/cdm/FolderModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ export type TableDataType = {
8282
}
8383

8484
export interface DatabaseHeaderProps {
85-
column: Column<RowDataType, any>,
86-
header: Header<RowDataType, TableColumn>,
85+
column: Column<RowDataType, Literal>,
86+
header: Header<RowDataType, Literal>,
8787
table: Table<RowDataType>
8888
}
8989

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,

src/components/headerActions/handlers/buttons/SortHandlerAction.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export default class SortHandlerAction extends AbstractHeaderAction {
1515
const column = this.globalHeaderActionResponse.headerMenuProps.headerProps
1616
.column.columnDef as TableColumn;
1717
switch (column.input) {
18-
case InputType.TAGS:
1918
case InputType.TASK:
2019
// DO NOTHING
2120
break;

src/components/portals/TagsPortal.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import React, { useState } from "react";
77
import { ActionMeta, OnChangeValue } from "react-select";
88
import { c } from "helpers/StylesHelper";
99
import { Literal } from "obsidian-dataview/lib/data-model/value";
10-
import NoteInfo from "services/NoteInfo";
1110
import { TableColumn } from "cdm/FolderModel";
1211

1312
const TagsPortal = (tagsProps: TagsProps) => {
@@ -35,9 +34,6 @@ const TagsPortal = (tagsProps: TagsProps) => {
3534
: []
3635
);
3736

38-
/** Note info of current Cell */
39-
const note: NoteInfo = (defaultCell.row.original as any).__note__;
40-
4137
function getColor(tag: string) {
4238
const match = tableColumn.options.find(
4339
(option: { label: string }) => option.label === tag
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)