Skip to content

fix: preserve falsy select filter values in FilterChip - #888

Merged
rohanchkrabrty merged 1 commit into
mainfrom
fix/filter-chip-falsy-filter-value
Aug 12, 2026
Merged

fix: preserve falsy select filter values in FilterChip#888
rohanchkrabrty merged 1 commit into
mainfrom
fix/filter-chip-falsy-filter-value

Conversation

@rsbh

@rsbh rsbh commented Aug 12, 2026

Copy link
Copy Markdown
Member

Description

A DataView select filter whose option value is 0 looked unset even though the filter was applied.

FilterChip seeded its internal value state with value || '', so 0 (and any other falsy option value) was discarded on mount:

const [filterValue, setFilterValue] = useState<any>(value || '');

Flow for filterOptions: [{ label: 'Zero', value: 0 }, ...]:

  1. useFilters.onAddFilter seeds the query filter with options[0]?.value0. The query is correct and the filter applies.
  2. FilterChip's internal state collapses to ''.
  3. Select.Value (hasValue = !!value) therefore renders the "Select value" placeholder.

Net effect: the chip reads as unset while a 0 filter is active. The same coercion blanked the Input for defaultFilterValue: 0 on number and string columns.

Fix is to use ?? so only null/undefined fall back to the empty string. String(0)"0" then matches the Select.Item value, which Select already stringifies, so the chip renders the option's label.

DataTable renders the same FilterChip, so it inherits the fix.

Deliberately out of scope

Two adjacent issues found while tracing this, left for separate PRs to keep the change minimal:

  • Picking a numeric option still emits the string "0", since Select stringifies item values. Client-side filtering is unaffected (select.eq compares via String()), but a server-side consumer with dataType: 'number' receives numberValue: "0".
  • useFilters seeds multiselect defaults as '' rather than [].

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

vitest --run over filter-chip, data-view, and data-table — 333 passed, 1 pre-existing skip (data-view/__tests__/debug.test.tsx). No new tests were added for the falsy case.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have made corresponding changes to the documentation (.mdx files) — not applicable, no API change
  • I have added tests that prove my fix is effective or that my feature works — not added

Related Issues

N/A

🤖 Generated with Claude Code

FilterChip seeded its internal value state with `value || ''`, so a falsy
option value was discarded on mount. A DataView select filter whose first
option is `0` applied `0` to the query but rendered the "Select value"
placeholder, leaving the chip visibly unset while a filter was active. The
same coercion blanked the Input for `defaultFilterValue: 0` on number and
string columns.

Use `??` so only null/undefined fall back to the empty string.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
apsara Ready Ready Preview Aug 12, 2026 4:30am

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@rsbh, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7af74919-e437-458e-9762-aa07efabe02a

📥 Commits

Reviewing files that changed from the base of the PR and between 8d138d4 and 4f5dede.

📒 Files selected for processing (1)
  • packages/raystack/components/filter-chip/filter-chip.tsx

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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/raystack/apsara/@raystack/apsara@888

commit: 4f5dede

@rohanchkrabrty
rohanchkrabrty merged commit 1ce8dc7 into main Aug 12, 2026
7 checks passed
@rohanchkrabrty
rohanchkrabrty deleted the fix/filter-chip-falsy-filter-value branch August 12, 2026 05:09
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