Skip to content

fix(ui): avoid duplicate data table filter bars - #16739

Open
HarshaJ99 wants to merge 3 commits into
medusajs:developfrom
HarshaJ99:fix/datatable-filter-isolation
Open

fix(ui): avoid duplicate data table filter bars#16739
HarshaJ99 wants to merge 3 commits into
medusajs:developfrom
HarshaJ99:fix/datatable-filter-isolation

Conversation

@HarshaJ99

@HarshaJ99 HarshaJ99 commented Sep 6, 2026

Copy link
Copy Markdown

What

Fixes #16623.

Prevent DataTable.Toolbar from rendering a duplicate filter bar when a consumer provides an explicit <DataTable.FilterBar /> as a direct toolbar child.

Why

DataTable.Toolbar already renders a DataTable.FilterBar internally. 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.FilterBar child using React.Children.toArray.

When an explicit filter bar is present:

  • it is removed from the main toolbar row;
  • it is rendered once below the toolbar row in the normal filter-bar position;
  • its existing props are preserved;
  • the toolbar does not mount its automatic filter bar.

When no explicit filter bar is provided, existing behavior is unchanged. alwaysShowFilterBar remains the supported way to reserve the empty filter-bar row.

Testing

Added data-table-toolbar.spec.tsx covering:

  • the default toolbar renders exactly one automatic filter bar;
  • an explicit DataTable.FilterBar child is used instead of rendering a second one;
  • the explicit filter bar's props are preserved.

The Medusa automated review also confirmed the direct child.type === DataTableFilterBar comparison is reliable here because DataTableFilterBar is not wrapped in React.memo or React.forwardRef.

Changeset

Added a patch changeset for @medusajs/ui.

@changeset-bot

changeset-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6a418ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 83 packages
Name Type
@medusajs/ui Patch
@medusajs/draft-order Patch
@medusajs/loyalty-plugin Patch
@medusajs/dashboard Patch
@medusajs/medusa Patch
@medusajs/admin-bundler Patch
@medusajs/test-utils Patch
@medusajs/medusa-oas-cli Patch
integration-tests-http Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/search Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/search-postgres Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/auth-oidc Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/instantsearch-adapter Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/query Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
create-medusa-app Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/eslint-plugin Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch

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

@HarshaJ99
HarshaJ99 marked this pull request as ready for review September 6, 2026 08:09
@HarshaJ99
HarshaJ99 requested review from a team as code owners September 6, 2026 08:09
@medusa-os-bot

medusa-os-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DataTable.FilterBar weird behavior: not visible when no filters, duplicated on filtering

1 participant