Skip to content

Conversation

bhaugeea
Copy link

@bhaugeea bhaugeea commented Aug 8, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Ensures column filter metadata is correctly propagated to leaf rows during leaf-based filtering, resolving inconsistent results and missing/incorrect filter states in grouped or nested tables. Users should now see consistent filter behavior and indicators across all hierarchy levels.
  • Tests
    • No changes to public APIs.

Copy link

coderabbitai bot commented Sep 8, 2025

Walkthrough

Propagates columnFiltersMeta to newly created leaf rows in filterRowModelFromLeafs, aligning it with columnFilters during leaf-based filtering. No public API or control-flow changes.

Changes

Cohort / File(s) Change Summary
Filtering metadata propagation
packages/table-core/src/utils/filterRowsUtils.ts
When creating leaf rows in filterRowModelFromLeafs, now copies columnFiltersMeta from the source row alongside columnFilters to ensure metadata is preserved.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Table as Table Core
  participant Filter as filterRowModelFromLeafs
  participant Leaf as New Leaf Row(s)

  User->>Table: Trigger filtering
  Table->>Filter: Build row model from leafs
  rect rgb(240,248,255)
    note right of Filter: For each matched row
    Filter->>Leaf: Create new leaf row
    Filter->>Leaf: Copy columnFilters
    Filter->>Leaf: Copy columnFiltersMeta (new)
  end
  Filter-->>Table: Return filtered leaf row model
  Table-->>User: Render filtered rows
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A hop, a skip, a meta-tag in tow,
I carry filters where the leaf rows go.
Tiny bytes align, like trails in snow—
No APIs stirred, just tidy flow.
Thump-thump! says the reviewer’s heart:
“One small copy, a well-placed art.” 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/table-core/src/utils/filterRowsUtils.ts (3)

104-115: Mirror filter-state copy in root-path clone for consistency

When cloning a row in filterRowModelFromRoot, also copy columnFilters and columnFiltersMeta to avoid surprises if downstream consumers read these on cloned parents.

Apply:

           const newRow = createRow(
             table,
             row.id,
             row.original,
             row.index,
             row.depth,
             undefined,
             row.parentId
           )
+          newRow.columnFilters = row.columnFilters
+          newRow.columnFiltersMeta = row.columnFiltersMeta
           newRow.subRows = recurseFilterRows(row.subRows, depth + 1)
           row = newRow

44-68: Avoid repeated filterRow(row) calls; compute once

Minor perf/readability: filterRow(row) is evaluated multiple times per row. Cache the result.

       if (row.subRows?.length && depth < maxDepth) {
         newRow.subRows = recurseFilterRows(row.subRows, depth + 1)
         row = newRow
-
-        if (filterRow(row) && !newRow.subRows.length) {
+        const pass = filterRow(row)
+        if (pass && !newRow.subRows.length) {
           rows.push(row)
           newFilteredRowsById[row.id] = row
           newFilteredFlatRows.push(row)
           continue
         }
 
-        if (filterRow(row) || newRow.subRows.length) {
+        if (pass || newRow.subRows.length) {
           rows.push(row)
           newFilteredRowsById[row.id] = row
           newFilteredFlatRows.push(row)
           continue
         }
       } else {
         row = newRow
-        if (filterRow(row)) {
+        const pass = filterRow(row)
+        if (pass) {
           rows.push(row)
           newFilteredRowsById[row.id] = row
           newFilteredFlatRows.push(row)
         }
       }

41-42: Confirm immutability; add a small regression test

These assignments copy references. If columnFilters/columnFiltersMeta can be mutated per-row downstream, consider shallow-cloning to avoid aliasing; otherwise current approach is fine. Also worth a regression test that asserts columnFiltersMeta is preserved when filterFromLeafRows=true.

I can draft a focused test that builds a nested row model, sets columnFilters/columnFiltersMeta, runs both leaf and root filtering, and asserts preservation. Want me to add it?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c62cf2 and 9333d0f.

📒 Files selected for processing (1)
  • packages/table-core/src/utils/filterRowsUtils.ts (1 hunks)
🔇 Additional comments (1)
packages/table-core/src/utils/filterRowsUtils.ts (1)

41-43: LGTM: Preserve columnFiltersMeta with leaf-row cloning

Copying columnFiltersMeta alongside columnFilters fixes the metadata loss when filterFromLeafRows is enabled. Looks correct.

@bhaugeea bhaugeea force-pushed the fix-column-filters-meta branch from 9333d0f to 32acc97 Compare September 18, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant