Skip to content

fix(data-table): keep column filters applied when Hide Empty Types hides rows - #2161

Open
paustint wants to merge 3 commits into
mainfrom
fix/data-table-set-filter-hide-empty-types
Open

paustint wants to merge 3 commits into
mainfrom
fix/data-table-set-filter-hide-empty-types

Conversation

@paustint

Copy link
Copy Markdown
Contributor

On Deploy Metadata, checking Hide Empty Types made the column filters stop applying. For example, deselecting LoggerCore in the Name filter still showed LoggerCore.

Cause

The shared grid counted a checkbox (SET) filter as active only while selected.length < distinctValues.length. Hide Empty Types removes the blank-name rows, but the saved selection still holds the blank value. In the reported case that made the counts equal ([blank, apexEmailNotifications] vs [apexEmailNotifications, LoggerCore]), so the filter silently switched off while the popover still showed LoggerCore unchecked. The same thing happens in any grid whose data loses a selected value, e.g. once loading rows finish.

Fix

  • Whether a SET filter is narrowing is now a membership check (isSetFilterNarrowing): it is active if any current value is deselected. The "was everything selected" check that runs when data changes uses the same test, so it no longer resets a customized filter by mistake.
  • Selections keep values that drop out of the data, so turning Hide Empty Types back off restores the empty types if the blank value was still selected.
  • The membership check is O(distinct values), so active filters are now worked out once per column when columnFilters is built, not on every row inside jetstreamColumnFilterFn.

Tests

  • useJetstreamTable.spec: a SET filter keeps narrowing when the data drops a selected value, and that value is still selected when it returns.
  • DeployMetadataDeploymentTable.spec: Name filter → Hide Empty Types on → still filtered → off → empty type returns. Confirmed this fails without the fix.
  • grid-filters.spec: updated to the new isFilterActive signature, plus stale-value cases.
  • ui + features-deploy typecheck and tests pass. RecordDownloadModal.spec failed once during the full ui run and passed 3 out of 3 times on its own; it is unrelated to this change.

…des rows

A checkbox (SET) filter only counted as active while fewer values were
selected than the column has. Hide Empty Types removes the blank-name rows,
so a selection still holding the blank value matched that count and the
filter silently stopped applying. Activeness is now a membership check.

Selections keep values that leave the data, so they keep their checked state
when those rows return. The check is O(distinct values), so active filters
are resolved once per column instead of per row.
Copilot AI balanced review requested due to automatic review settings October 17, 2026 13:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The reset condition can silently reselect excluded values after data shrinks or becomes empty and then returns.

1 open issue
What changed in this PR

Fixes shared-grid SET filters becoming inactive when Deploy Metadata’s Hide Empty Types removes selected values.

Changes:

  • Detects active SET filters using membership rather than counts.
  • Computes active filters once per column instead of per row.
  • Adds shared-grid and Deploy Metadata regression tests.
File Description
libs/​ui/​src/​lib/​data-table/​grid/​grid-filters.ts Adds membership-based filter detection.
libs/​ui/​src/​lib/​data-table/​grid/​filters/​HeaderFilters.tsx Updates filter indicator checks.
libs/​ui/​src/​lib/​data-table/​grid/​filterFns.ts Uses precomputed active filters.
libs/​ui/​src/​lib/​data-table/​grid/​core/​useJetstreamTable.ts Updates selection reset and filter construction.
libs/​ui/​src/​lib/​data-table/​grid/​__tests__/​useJetstreamTable.spec.tsx Tests selection retention across data changes.
libs/​ui/​src/​lib/​data-table/​grid/​__tests__/​grid-filters.spec.ts Tests stale selected values.
libs/​features/​deploy/​src/​__tests__/​DeployMetadataDeploymentTable.spec.tsx Tests filtering while toggling empty types.

Review effort: Balanced

Comment thread libs/ui/src/lib/data-table/grid/core/useJetstreamTable.ts Outdated
…and returns

Coverage alone treated a selection as "all selected" once the data shrank to
values it still covered, so restoring the data reselected values the user had
excluded. The reset now also requires matching length, which the old check
used and which still catches stale selected values.
Copilot AI balanced review requested due to automatic review settings October 18, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Restoring data can still reselect previously deselected values when the reduced dataset exactly matches the retained selection.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread libs/ui/src/lib/data-table/grid/core/useJetstreamTable.ts Outdated
Comparing a selection with the previous distinct values could not tell a
narrowed filter from an untouched one once the data shrank to exactly the
selected values, so restoring the data reselected the rest. Deselecting the
blank Name and toggling Hide Empty Types on and off brought the empty types
back. The reducer now records which columns the user narrowed.
Copilot AI balanced review requested due to automatic review settings October 18, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No blocking issues were identified, and regression coverage addresses filter activation and selection restoration.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants