fix: preserve falsy select filter values in FilterChip - #888
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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. Comment |
commit: |
Description
A DataView
selectfilter whose option value is0looked unset even though the filter was applied.FilterChipseeded its internal value state withvalue || '', so0(and any other falsy option value) was discarded on mount:Flow for
filterOptions: [{ label: 'Zero', value: 0 }, ...]:useFilters.onAddFilterseeds the query filter withoptions[0]?.value→0. The query is correct and the filter applies.FilterChip's internal state collapses to''.Select.Value(hasValue = !!value) therefore renders the "Select value" placeholder.Net effect: the chip reads as unset while a
0filter is active. The same coercion blanked theInputfordefaultFilterValue: 0onnumberandstringcolumns.Fix is to use
??so onlynull/undefinedfall back to the empty string.String(0)→"0"then matches theSelect.Itemvalue, whichSelectalready stringifies, so the chip renders the option's label.DataTablerenders the sameFilterChip, 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:
"0", sinceSelectstringifies item values. Client-side filtering is unaffected (select.eqcompares viaString()), but a server-side consumer withdataType: 'number'receivesnumberValue: "0".useFiltersseedsmultiselectdefaults as''rather than[].Type of Change
How Has This Been Tested?
vitest --runoverfilter-chip,data-view, anddata-table— 333 passed, 1 pre-existing skip (data-view/__tests__/debug.test.tsx). No new tests were added for the falsy case.Checklist:
Related Issues
N/A
🤖 Generated with Claude Code