Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(table): solve searchable filter bug #949

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/oruga/src/components/table/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,9 @@ function isRowEqual(
const filters = ref<Record<string, string>>({});

watch(
filters.value,
filters,
(value) => {
if (!props.backendFiltering) return;
if (props.backendFiltering) return;
if (props.debounceSearch)
useDebounce(
() => handleFiltersChange(value),
Expand All @@ -1022,6 +1022,7 @@ function onFiltersEvent(event: Event): void {

/** check whether a row is filtered by filter or not */
function isRowFiltered(row: T): boolean {
if (!Object.values(filters.value).filter(Boolean).length) return true;
return Object.entries(filters.value).some(([key, filter]) => {
if (!filter) return false;
// get column for filter
Expand All @@ -1046,7 +1047,7 @@ function isRowFiltered(row: T): boolean {
}

function filterRows(rows: TableRow<T>[]): TableRow<T>[] {
return rows.filter((row) => !isRowFiltered(row.value));
return rows.filter((row) => isRowFiltered(row.value));
}

// --- Sort Feature ---
Expand Down
Loading