fix(ui): avoid duplicate data table filter bars - #16739
Conversation
🦋 Changeset detectedLatest commit: 6a418ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 83 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the contribution! Initial automated review looks good. The author addresses a bug in DataTableToolbar where providing an explicit DataTable.FilterBar as a direct toolbar child caused two filter bars to render from the same filtering state. The fix uses React.Children.toArray to detect an explicit DataTableFilterBar child, hoists it below the toolbar row in place of the automatic one, and leaves the remaining toolbar children untouched. When no explicit bar is provided, existing behavior is fully preserved. The PR includes a new spec file (data-table-toolbar.spec.tsx) covering the two relevant scenarios: no explicit filter bar (one automatic bar renders) and an explicit filter bar (used instead of the automatic one, props preserved). The comparison child.type === DataTableFilterBar is reliable here because DataTableFilterBar is not wrapped in React.memo or React.forwardRef. The changeset is correctly typed as patch and follows the required message format. All conventions are followed — no semicolons, double quotes, trailing commas, and correct file naming. Minor note: the PR body does not use the explicit What, Why, How sub-sections from the pull request template. The information is present in the narrative prose, so this is an observation rather than a blocker. Triggered by: PR marked as ready for review |
What
Fixes #16623.
Prevent
DataTable.Toolbarfrom rendering a duplicate filter bar when a consumer provides an explicit<DataTable.FilterBar />as a direct toolbar child.Why
DataTable.Toolbaralready renders aDataTable.FilterBarinternally. When a consumer also rendered<DataTable.FilterBar />inside the toolbar, both bars observed the same filtering state. With no active filters, both were hidden. Once filtering became active, both rendered the same filter chips, matching the reported "missing when empty, duplicated when filtering" behavior.How
The toolbar now detects an explicit direct
DataTable.FilterBarchild usingReact.Children.toArray.When an explicit filter bar is present:
When no explicit filter bar is provided, existing behavior is unchanged.
alwaysShowFilterBarremains the supported way to reserve the empty filter-bar row.Testing
Added
data-table-toolbar.spec.tsxcovering:DataTable.FilterBarchild is used instead of rendering a second one;The Medusa automated review also confirmed the direct
child.type === DataTableFilterBarcomparison is reliable here becauseDataTableFilterBaris not wrapped inReact.memoorReact.forwardRef.Changeset
Added a patch changeset for
@medusajs/ui.