Skip to content

Fix ColumnsSelector cannot hide DataTable.Col items with no source#11088

Merged
slax57 merged 2 commits intomasterfrom
Fic-ColumnsSelector-cannot-hide-DataTable-cols-with-no-source
Dec 17, 2025
Merged

Fix ColumnsSelector cannot hide DataTable.Col items with no source#11088
slax57 merged 2 commits intomasterfrom
Fic-ColumnsSelector-cannot-hide-DataTable-cols-with-no-source

Conversation

@fzaninotto
Copy link
Member

Closes #11087

I fixed both the bug with columns with no source and the button alignment problems.

How To Test

  • Run the simple example with make run
  • Navigate to the post lists page.
  • Click on the Columns selector button
  • Toggle the display of NbComments
  • This should hide the nb comments column

Or test in the storybook: http://localhost:9010/?path=/story/ra-ui-materialui-list-columnsbutton--no-source

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests
  • The PR includes one or several stories
  • The documentation is up to date

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where DataTable columns without a source prop could not be hidden using the ColumnsSelector. The fix introduces a fallback mechanism that uses the column's label (when it's a string) as the identifier for column visibility when source is undefined. Additionally, it corrects a Button API usage issue in the ColumnsSelector by changing from using children to the label prop.

Key changes:

  • Columns without source now use their string label as the identifier in the hidden columns logic
  • Button component in ColumnsSelector now correctly uses the label prop instead of children
  • Added comprehensive test coverage for columns without source

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
DataTableHeadCell.tsx Updated to check column visibility using source ?? label fallback
DataTableCell.tsx Updated to check column visibility using source ?? label fallback
ColumnsSelectorItem.tsx Added validation to ensure label is a string when source is missing, and uses sourceOrLabel throughout
ColumnsSelector.tsx Fixed Button usage to use label prop instead of children
ColumnsButton.stories.tsx Added NoSource story to demonstrate columns without source
ColumnsButton.spec.tsx Added test case for columns without source

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@slax57 slax57 added this to the 5.13.5 milestone Dec 17, 2025
@slax57 slax57 merged commit 6065878 into master Dec 17, 2025
21 checks passed
@slax57 slax57 deleted the Fic-ColumnsSelector-cannot-hide-DataTable-cols-with-no-source branch December 17, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Development

Successfully merging this pull request may close these issues.

Cannot hide columns in <DataTable /> through <ColumnsButton />

2 participants