From be97b81534c5952038b6df8cbcdf36074512ecfc Mon Sep 17 00:00:00 2001 From: greymoth-jp Date: Sun, 28 Jun 2026 21:57:10 +0000 Subject: [PATCH 1/2] fix(table-core): auto-remove empty arrHas filter values like the other array filters arrHas was the only array-valued filter function without an autoRemove handler, so an empty array filter value was never removed and hid every row. --- packages/table-core/src/fns/filterFns.ts | 20 ++++++++--------- .../tests/unit/fns/filterFns.test.ts | 22 +++++++++++++++++++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/packages/table-core/src/fns/filterFns.ts b/packages/table-core/src/fns/filterFns.ts index 7e85698890..47995dc239 100644 --- a/packages/table-core/src/fns/filterFns.ts +++ b/packages/table-core/src/fns/filterFns.ts @@ -296,16 +296,16 @@ export const filterFn_inNumberRange = Object.assign( /** * Keeps rows whose scalar column value equals at least one filter value. */ -export const filterFn_arrHas = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: Array, -) => { - return filterValue.some((val) => row.getValue(columnId) === val) -} +export const filterFn_arrHas = Object.assign( + ( + row: Row, + columnId: string, + filterValue: Array, + ) => { + return filterValue.some((val) => row.getValue(columnId) === val) + }, + { autoRemove: (val: any) => testFalsy(val) || !val?.length }, +) /** * Keeps rows whose array or string column value includes at least one filter value. diff --git a/packages/table-core/tests/unit/fns/filterFns.test.ts b/packages/table-core/tests/unit/fns/filterFns.test.ts index 1b6f74a092..79adcb4de4 100644 --- a/packages/table-core/tests/unit/fns/filterFns.test.ts +++ b/packages/table-core/tests/unit/fns/filterFns.test.ts @@ -563,4 +563,26 @@ describe('Filter Functions', () => { }) }) }) + + describe('Array Filters', () => { + describe('filterFns.arrHas.autoRemove', () => { + const autoRemove = filterFns.arrHas.autoRemove! + + it('should auto-remove when the filter value is undefined', () => { + expect(autoRemove(undefined)).toBe(true) + }) + it('should auto-remove when the filter value is null', () => { + expect(autoRemove(null)).toBe(true) + }) + it('should auto-remove when the filter value is an empty string', () => { + expect(autoRemove('')).toBe(true) + }) + it('should auto-remove when the filter value is an empty array', () => { + expect(autoRemove([])).toBe(true) + }) + it('should NOT auto-remove when the filter value is a non-empty array', () => { + expect(autoRemove(['a'])).toBe(false) + }) + }) + }) }) From 426274af9ef5bab6a1543acc3ca8ec2dccd7adbf Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 28 Jun 2026 23:12:40 +0000 Subject: [PATCH 2/2] ci: apply automated fixes --- .../with-tanstack-form/src/app/app.html | 14 +++++++----- .../src/app/header-components.ts | 22 ++++++++++++------- .../src/app/row-submit-table-row.ts | 4 +++- .../src/app/table-components.ts | 8 ++----- .../preact/with-tanstack-form/src/form.tsx | 5 +---- .../react/with-tanstack-form/src/form.tsx | 5 +---- examples/solid/with-tanstack-form/src/App.tsx | 4 +--- .../solid/with-tanstack-form/src/index.tsx | 4 +++- .../solid/with-tanstack-form/src/table.tsx | 6 ++--- examples/vue/with-tanstack-form/src/App.vue | 4 +++- examples/vue/with-tanstack-form/src/table.ts | 17 +++----------- 11 files changed, 42 insertions(+), 51 deletions(-) diff --git a/examples/angular/with-tanstack-form/src/app/app.html b/examples/angular/with-tanstack-form/src/app/app.html index a26a9f84f8..7de54ccab9 100644 --- a/examples/angular/with-tanstack-form/src/app/app.html +++ b/examples/angular/with-tanstack-form/src/app/app.html @@ -4,10 +4,16 @@

Single form around the table

- + {{ fullFormState().isDirty ? 'Modified' : 'Pristine' }} - + {{ fullFormState().isValid ? 'Valid' : 'Invalid' }}
@@ -18,9 +24,7 @@

Single form around the table

> {{ fullFormState().isSubmitting ? 'Submitting...' : 'Save All Changes' }} - + diff --git a/examples/angular/with-tanstack-form/src/app/header-components.ts b/examples/angular/with-tanstack-form/src/app/header-components.ts index ef725bbbdd..8dcf792cb1 100644 --- a/examples/angular/with-tanstack-form/src/app/header-components.ts +++ b/examples/angular/with-tanstack-form/src/app/header-components.ts @@ -61,22 +61,28 @@ export class _ColumnFilter { .getPreFilteredRowModel() .flatRows[0]?.getValue(this.header().column.id), ) - readonly isNumberColumn = computed(() => typeof this.firstValue() === 'number') + readonly isNumberColumn = computed( + () => typeof this.firstValue() === 'number', + ) readonly filterValue = computed(() => this.header().column.getFilterValue()) readonly numberFilterValue = computed( () => this.filterValue() as [number, number] | undefined, ) - readonly textFilterValue = computed(() => (this.filterValue() ?? '') as string) + readonly textFilterValue = computed( + () => (this.filterValue() ?? '') as string, + ) setMin(value: string | number) { - this.header().column.setFilterValue( - (old: [number, number] | undefined) => [value, old?.[1]], - ) + this.header().column.setFilterValue((old: [number, number] | undefined) => [ + value, + old?.[1], + ]) } setMax(value: string | number) { - this.header().column.setFilterValue( - (old: [number, number] | undefined) => [old?.[0], value], - ) + this.header().column.setFilterValue((old: [number, number] | undefined) => [ + old?.[0], + value, + ]) } } diff --git a/examples/angular/with-tanstack-form/src/app/row-submit-table-row.ts b/examples/angular/with-tanstack-form/src/app/row-submit-table-row.ts index 70f7b7ab91..9e6114805d 100644 --- a/examples/angular/with-tanstack-form/src/app/row-submit-table-row.ts +++ b/examples/angular/with-tanstack-form/src/app/row-submit-table-row.ts @@ -146,7 +146,9 @@ import type { Row } from '@tanstack/angular-table'