Skip to content
Source
Sign inSign up
TanStack/table

fix global filtering with undefined first values #6438

MergedKevinVandymerged 3 commits intobeta fromrefs/pull/6438/headmerged by KevinVandy

KevinVandycommented

What changed

  • determine default global-filter eligibility from the first non-nullish value in a column
  • preserve the existing behavior of enabling string and number columns only
  • add a regression test covering an undefined first value followed by searchable strings

Why

The default eligibility predicate sampled only the first row. When that row had an undefined value, the entire column was excluded from global filtering even when later rows contained valid strings or numbers. This made results depend on row order.

Validation

  • reproduced the failure on beta before applying the implementation change
  • table-core test suite: 52 files, 1,005 tests passed
  • table-core TypeScript and declaration-emit checks passed
  • table-core ESLint passed
  • Prettier and git diff checks passed

Closes #4783

Summary by CodeRabbit

  • Bug Fixes

    • Global filtering now correctly evaluates columns when the first row has a blank value.
    • Filtering works as expected when matching values appear in later rows.
    • Columns explicitly enabled for global filtering can now be filtered even when they contain object values, using a custom filter.
  • Tests

    • Added coverage for undefined values in the first row and explicitly enabled object-valued columns.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      📝 Walkthrough

      Walkthrough

      Global filtering now honors explicit enablement and checks the first non-null value in a column when determining filterability. A regression test covers filtering data where the first row’s value is undefined.

      Changes

      Global filtering fix

      Layer / File(s)Summary
      Non-null column value detection and regression coverage
      packages/table-core/src/features/global-filtering/globalFilteringFeature.ts, packages/table-core/tests/implementation/features/column-filtering/createFilteredRowModel.test.ts
      getColumnCanGlobalFilter honors enableGlobalFilter: true and uses the first non-null cell value for type detection. A test verifies that global filtering finds a later matching row when the first row is undefined.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Possibly related PRs

      • TanStack/table#6439: Modifies getColumnCanGlobalFilter and adds tests for explicit global-filter enablement on object-valued columns.
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title clearly describes the fix for global filtering when the first column value is undefined.
      Linked Issues check✅ PassedThe implementation and regression tests address the undefined-first-value global filtering bug described in [#4783].
      Out of Scope Changes check✅ PassedThe code and test changes are directly related to fixing and validating global-filter eligibility.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      ✨ Finishing Touches
      📝 Generate docstrings
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `agent/fix-4783-global-filter-null-first`

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 19ea6997e45a3eb8cdda111f11ddaf075d16c6ab

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded6m 15sView ↗
      nx run-many --targets=build --exclude=examples/**✅ Succeeded51sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-07-31 00:11:58 UTC

    3. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @tanstack/alpine-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/alpine-table@6438

      @tanstack/angular-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6438

      @tanstack/angular-table-devtools

      npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table-devtools@6438

      @tanstack/ember-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/ember-table@6438

      @tanstack/lit-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6438

      @tanstack/match-sorter-utils

      npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6438

      @tanstack/preact-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6438

      @tanstack/preact-table-devtools

      npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table-devtools@6438

      @tanstack/react-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6438

      @tanstack/react-table-devtools

      npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6438

      @tanstack/solid-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6438

      @tanstack/solid-table-devtools

      npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6438

      @tanstack/svelte-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6438

      @tanstack/table-core

      npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6438

      @tanstack/table-devtools

      npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6438

      @tanstack/vue-table

      npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6438

      @tanstack/vue-table-devtools

      npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table-devtools@6438

      commit: 19ea699

    4. credit to @SAY-5 for PRing a fix in https://github.com/TanStack/table/pull/6252

    5. Caution

      Some comments are outside the diff and can’t be posted inline due to platform limitations.

      ⚠️ Outside diff range comments (1)
      packages/table-core/tests/implementation/features/column-filtering/createFilteredRowModel.test.ts (1)

      551-577: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

      Cover the undefined-first-row regression directly.

      This test exercises the explicit enableGlobalFilter: true branch, so it never validates the new first non-nullish lookup. Add a case with the first row’s value undefined, a later searchable string, and no explicit opt-in; assert that the later row is returned.

      🤖 Prompt for AI Agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      In
      `@packages/table-core/tests/implementation/features/column-filtering/createFilteredRowModel.test.ts`
      around lines 551 - 577, Extend the global filtering tests near the explicit
      opt-in case with a column whose first row value is undefined and a later row
      contains a searchable string, without setting enableGlobalFilter. Configure the
      filter to match that string and assert that only the later row is returned,
      covering the first non-nullish value lookup.
      🤖 Prompt for all review comments with AI agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      Outside diff comments:
      In
      `@packages/table-core/tests/implementation/features/column-filtering/createFilteredRowModel.test.ts`:
      - Around line 551-577: Extend the global filtering tests near the explicit
      opt-in case with a column whose first row value is undefined and a later row
      contains a searchable string, without setting enableGlobalFilter. Configure the
      filter to match that string and assert that only the later row is returned,
      covering the first non-nullish value lookup.

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 4287a756-7fce-4b86-aada-f6438bc84c77

      📥 Commits

      Reviewing files that changed from the base of the PR and between ec312a87423fa9d7d2f583135496d847b0682308 and 19ea6997e45a3eb8cdda111f11ddaf075d16c6ab.

      📒 Files selected for processing (2)
      • packages/table-core/src/features/global-filtering/globalFilteringFeature.ts
      • packages/table-core/tests/implementation/features/column-filtering/createFilteredRowModel.test.ts
    6. KevinVandy merged thise321f3f

    7. KevinVandy closed this

Sign in to join this conversation.