Skip to content

feat(data_table): support custom label and initial column visibility in DataTableColumnToggle#466

Merged
cirdes merged 4 commits into
ruby-ui:mainfrom
pierry01:feat/data-table-column-toggle
Jul 10, 2026
Merged

feat(data_table): support custom label and initial column visibility in DataTableColumnToggle#466
cirdes merged 4 commits into
ruby-ui:mainfrom
pierry01:feat/data-table-column-toggle

Conversation

@pierry01

@pierry01 pierry01 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What & why

DataTableColumnToggle hardcodes the trigger label to "Columns" and always renders every column as initially visible. This adds two small, backward-compatible options:

  • label: (default "Columns") — localize or rename the trigger button.
  • per-column visible: key (default true) — let a column start hidden (checkbox unchecked) on first render.

It also adds checked: utility classes to the checkbox so the selected state reads clearly in light and dark themes.

Usage

render RubyUI::DataTableColumnToggle.new(
  label: "Colunas",
  columns: [
    {key: :email, label: "Email"},
    {key: :salary, label: "Salary", visible: false}
  ]
)

Before / after

Before After
image image

Notes

  • Backward compatible: label defaults to "Columns" and visible defaults to true, so existing call sites are unchanged.
  • mcp/data/registry.json rebuilt for the updated component.

pierry01 and others added 2 commits July 9, 2026 14:55
…in DataTableColumnToggle

Adds a `label:` option (defaults to "Columns") so the trigger text can be
localized/customized, and reads `:visible` per column so a column can start
hidden (checkbox unchecked). Also adds `checked:` styling to the checkbox.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="gem/test/ruby_ui/data_table_column_toggle_test.rb">

<violation number="1" location="gem/test/ruby_ui/data_table_column_toggle_test.rb:38">
P3: The assertion `assert_equal 1, output.scan("checked class=").length` ties the test to attribute ordering in the rendered HTML. If someone moves `class:` above `checked:` in the component template, this test breaks even though the checked/unchecked behavior is unchanged. Consider a regex that matches `checked` as a standalone boolean attribute regardless of position, e.g. `output.scan(/\bchecked(?:\s|>)/).length` which won't match `checked:` inside class values but will match the boolean `checked` attribute.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread gem/test/ruby_ui/data_table_column_toggle_test.rb Outdated
@cirdes

cirdes commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

The visible: option only sets the checkbox's initial checked state — it does not actually hide the column on first render. The data-table-column-visibility controller has no connect(); it only toggles hidden on change events. So a column with visible: false renders visible while its checkbox shows unchecked, and stays out of sync until the user clicks it twice.

test_column_can_start_hidden only asserts on the checkbox output, never that the column is hidden, so it passes green over this gap.

Worth having the controller read the initial checkbox states on connect() and apply hidden accordingly, so the rendered column and its checkbox agree from the first paint.

@cirdes cirdes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please fix the issues

pierry01 and others added 2 commits July 9, 2026 19:04
…bleColumnToggle

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… in column toggle test

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cirdes cirdes merged commit d15167c into ruby-ui:main Jul 10, 2026
8 checks passed
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