fix: skip invalid date filters in DataTable#657
Conversation
…taTableQuery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe PR adds date filter validation to data-table utility functions using dayjs to ensure only valid dates are preserved during query transformations. Tests are expanded to cover date filter edge cases and new getDataType functionality. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/raystack/components/data-table/utils/index.tsx (1)
24-28: Consider handlingselectfilters consistently withtransformToDataTableQuery.The
transformToDataTableQueryfunction (line 197) explicitly allowsselectfilters through unconditionally withif (data._type === FilterType.select) return true;, butqueryToTableStatedoes not have this handling. This means empty select filter values would be filtered out in client mode but preserved in server mode.If this inconsistency is intentional (different requirements for client vs server), consider adding a comment to document this behavior. Otherwise, you may want to align the logic:
💡 Suggested change for consistency
const columnFilters = query.filters ?.filter(data => { + if (data._type === FilterType.select) return true; if (data._type === FilterType.date) return dayjs(data.value).isValid(); if (data.value !== '') return true; return false; })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/raystack/components/data-table/utils/index.tsx` around lines 24 - 28, In queryToTableState, align its filter logic with transformToDataTableQuery by explicitly allowing select filters: update the anonymous filter inside queryToTableState to return true when data._type === FilterType.select (or, if the difference is intentional, add a clear comment in queryToTableState explaining why selects are excluded) so select filters aren’t dropped in client mode; reference the FilterType.select symbol and the queryToTableState and transformToDataTableQuery functions when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/raystack/components/data-table/utils/index.tsx`:
- Around line 24-28: In queryToTableState, align its filter logic with
transformToDataTableQuery by explicitly allowing select filters: update the
anonymous filter inside queryToTableState to return true when data._type ===
FilterType.select (or, if the difference is intentional, add a clear comment in
queryToTableState explaining why selects are excluded) so select filters aren’t
dropped in client mode; reference the FilterType.select symbol and the
queryToTableState and transformToDataTableQuery functions when making the
change.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/raystack/components/data-table/utils/__tests__/filter-operations.test.tsxpackages/raystack/components/data-table/utils/__tests__/index.test.tsxpackages/raystack/components/data-table/utils/index.tsx
* fix: skip invalid date filters in queryToTableState and transformToDataTableQuery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add tests for invalid date filter validation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
queryToTableState(client mode) andtransformToDataTableQuery(server mode) instead of sending emptystringValuedayjs.isValid()before including in filter queryFollows up on #656
Test plan
stringValuesent, all rows visible)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests