Skip to content

fix: enhance boolean filter handling in SelectFilter component - #166

Merged
Romakita merged 1 commit into
masterfrom
fix-table-boolean-filter
Apr 24, 2026
Merged

Romakita merged 1 commit into
masterfrom
fix-table-boolean-filter

Conversation

@Romakita

@Romakita Romakita commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added an "Is open" boolean column to the table with Open/Closed filtering capabilities.
  • Tests

    • Enhanced test coverage for boolean filtering functionality.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Romakita has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 32 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 40 minutes and 32 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d2f87cc1-7789-45f6-a18f-a019908069cf

📥 Commits

Reviewing files that changed from the base of the PR and between 1c14d8c and 68e2797.

📒 Files selected for processing (3)
  • packages/react-formio/src/molecules/table/Table.stories.tsx
  • packages/react-formio/src/molecules/table/filters/SelectFilter.spec.tsx
  • packages/react-formio/src/molecules/table/filters/SelectFilter.tsx
📝 Walkthrough

Walkthrough

The changes extend the Table stories with a new boolean is_open field, add corresponding column configuration with boolean filter metadata and labels, and update SelectFilter to handle boolean filter variants with conditional value interpretation in the onChange handler.

Changes

Cohort / File(s) Summary
Table Stories Update
packages/react-formio/src/molecules/table/Table.stories.tsx
Extended ProductSubmission type to include is_open: boolean, updated fixture data with alternating boolean values, introduced centralized tableColumns configuration with new Is open boolean column (supporting Open/Closed labels), and updated all stories (Usage, WithFilters, WithPaginationOptions, WithCustomCell) to use the new data and column structure; also updated test assertions to validate the new column header and filter interactions.
SelectFilter Implementation
packages/react-formio/src/molecules/table/filters/SelectFilter.tsx
Added boolean filter variant detection that conditionally interprets selected values: clearing ("") sets undefined, selecting "true" sets true, other non-empty selections set false; non-boolean filters retain original behavior of directly setting the filter value from selection.
SelectFilter Tests
packages/react-formio/src/molecules/table/filters/SelectFilter.spec.tsx
New test suite validating SelectFilter behavior for both boolean and select variants, with mocked Select component registry state management via beforeEach/afterEach hooks.

Sequence Diagram

sequenceDiagram
    participant User
    participant SelectFilter
    participant Select
    participant Callback

    User->>SelectFilter: Update column config with filter variant
    SelectFilter->>Select: Render with value prop (normalized to string)
    User->>Select: Select option
    Select->>SelectFilter: onChange(selectedValue)
    
    alt Boolean Filter Variant
        SelectFilter->>SelectFilter: Detect variant="boolean"
        alt selectedValue = ""
            SelectFilter->>Callback: setFilterValue(undefined)
        else selectedValue = "true"
            SelectFilter->>Callback: setFilterValue(true)
        else Other non-empty value
            SelectFilter->>Callback: setFilterValue(false)
        end
    else Non-Boolean Filter
        SelectFilter->>Callback: setFilterValue(rawSelectedString)
    end
    
    Callback->>Callback: Update filter state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A boolean bloom in the filter's domain,
Where true and false dance in the chain,
Stories unfold with is_open so bright,
SelectFilter learns to interpret just right,
Tables now filter with newfound delight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enhancing boolean filter handling in the SelectFilter component, which is reflected across the modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-table-boolean-filter

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
packages/react-formio/src/molecules/table/filters/SelectFilter.spec.tsx (2)

39-39: Optional: also cover the controlled-value path for a boolean filter.

The current suite exercises onChange but never renders SelectFilter with a non-undefined boolean filter value, so the value={columnFilterValue === undefined ? "" : String(columnFilterValue)} branch on line 42 of SelectFilter.tsx is untested. A small case that stubs getFilterValue: () => false and asserts the <select> DOM value is "false" would lock in that behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-formio/src/molecules/table/filters/SelectFilter.spec.tsx` at
line 39, Add a test that renders SelectFilter with a non-undefined boolean
filter value to exercise the controlled-value branch: mock the column's
getFilterValue to return false (e.g., getFilterValue: () => false) when
rendering SelectFilter in SelectFilter.spec.tsx, then assert the rendered
<select> element's value is the string "false" (matching the component's
value={columnFilterValue === undefined ? "" : String(columnFilterValue)}
behavior); this ensures the controlled path for boolean values in SelectFilter
is covered.

20-44: Minor: redundant setFilterValue exposure.

setFilterValue is returned both at the top level of createHeader and assigned on header.column. They reference the same vi.fn(), so it works, but keeping only one (e.g., destructure from header.column.setFilterValue in the tests) would make the fixture shape harder to get out of sync.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-formio/src/molecules/table/filters/SelectFilter.spec.tsx`
around lines 20 - 44, The fixture currently exposes setFilterValue twice
(top-level setFilterValue and header.column.setFilterValue); remove the
redundant top-level setFilterValue from the object returned by createHeader and
update any tests to use header.column.setFilterValue instead so the single
vi.fn() remains only on header.column.setFilterValue and the fixture shape can't
drift out of sync.
packages/react-formio/src/molecules/table/Table.stories.tsx (1)

246-260: Reuse tableColumns in WithFilters for consistency.

WithPaginationOptions and Usage already pull their column definition from the centralized tableColumns, but WithFilters duplicates the is_open boolean-filter configuration inline. Inlining here drifts from the shared definition (e.g., the id: "is_open" explicit identity is missing) and any future change to the boolean column has to be mirrored in two places. Consider composing from tableColumns or a shared factory.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-formio/src/molecules/table/Table.stories.tsx` around lines 246
- 260, In WithFilters replace the duplicated inline boolean column definition
with the shared tableColumns entry: find the column in tableColumns whose
accessorKey is "data.is_open" and reuse it (or spread it into the WithFilters
columns array) so the boolean filter configuration is centralized; ensure the
reused column includes the explicit identity id: "is_open" and preserves
meta.filter.variant/layout and labels so behavior matches the other stories.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/react-formio/src/molecules/table/Table.stories.tsx`:
- Line 156: The current assertion uses canvas.queryByText("Kani") which can be
null and causes a TypeError when calling .closest("tr"); replace this with
canvas.getByText("Kani") to ensure the test fails clearly if the "Kani" row is
missing, then locate the row via .closest("tr") (on the guaranteed element) and
assert that its delete button lookup (querySelector('[data-testid$="-delete"]'))
is not.toBeInTheDocument(); update the assertion in the Table.stories test to
use getByText and perform the negative expectation only on the delete-button
query result.

---

Nitpick comments:
In `@packages/react-formio/src/molecules/table/filters/SelectFilter.spec.tsx`:
- Line 39: Add a test that renders SelectFilter with a non-undefined boolean
filter value to exercise the controlled-value branch: mock the column's
getFilterValue to return false (e.g., getFilterValue: () => false) when
rendering SelectFilter in SelectFilter.spec.tsx, then assert the rendered
<select> element's value is the string "false" (matching the component's
value={columnFilterValue === undefined ? "" : String(columnFilterValue)}
behavior); this ensures the controlled path for boolean values in SelectFilter
is covered.
- Around line 20-44: The fixture currently exposes setFilterValue twice
(top-level setFilterValue and header.column.setFilterValue); remove the
redundant top-level setFilterValue from the object returned by createHeader and
update any tests to use header.column.setFilterValue instead so the single
vi.fn() remains only on header.column.setFilterValue and the fixture shape can't
drift out of sync.

In `@packages/react-formio/src/molecules/table/Table.stories.tsx`:
- Around line 246-260: In WithFilters replace the duplicated inline boolean
column definition with the shared tableColumns entry: find the column in
tableColumns whose accessorKey is "data.is_open" and reuse it (or spread it into
the WithFilters columns array) so the boolean filter configuration is
centralized; ensure the reused column includes the explicit identity id:
"is_open" and preserves meta.filter.variant/layout and labels so behavior
matches the other stories.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cc691c62-a190-4533-adb5-2567374b1554

📥 Commits

Reviewing files that changed from the base of the PR and between 92b328a and 1c14d8c.

📒 Files selected for processing (3)
  • packages/react-formio/src/molecules/table/Table.stories.tsx
  • packages/react-formio/src/molecules/table/filters/SelectFilter.spec.tsx
  • packages/react-formio/src/molecules/table/filters/SelectFilter.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c14d8cabd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Romakita
Romakita force-pushed the fix-table-boolean-filter branch from 1c14d8c to 6c73dcc Compare April 24, 2026 14:20
@Romakita
Romakita force-pushed the fix-table-boolean-filter branch 2 times, most recently from 011dfaa to 68e2797 Compare April 24, 2026 14:22
@Romakita
Romakita merged commit 3220a4e into master Apr 24, 2026
10 checks passed
@Romakita

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 3.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant