⚡ NEW: WordPress/gutenberg/issues/ - HD Photos!

Skip to content

DataViews: Export DataViewsContext to enable custom layouts with individual components #71773

@johnhooks

Description

@johnhooks

What problem does this address?

It is currently difficult to create custom DataViews layouts using the newly exported individual components (DataViews.Search, DataViews.Filters, DataViews.FiltersToggle) because these components depend on DataViewsContext which is not exported.

When trying to reassemble DataViews with custom layouts, we cannot:

  • Access isShowingFilter state needed to conditionally render the Filters component
  • Coordinate between FiltersToggle and Filters components
  • Access other shared state like openedFilter, fields, view, and data

This prevents the composability that the v8 individual component exports seem to enable.

What is your proposed solution?

Export DataViewsContext from the main package:

export { DataViewsContext } from './components/dataviews-context';

This would allow developers to:

  1. Use useContext(DataViewsContext) to access shared state
  2. Create fully custom layouts while reusing the official filter/search components
  3. Properly coordinate component interactions through the context

The context export would complete the composability story started by exporting the individual components.

Metadata

Metadata

Assignees

Labels

[Feature] DataViewsWork surrounding upgrading and evolving views in the site editor and beyond[Package] DataViews/packages/dataviews[Status] In ProgressTracking issues with work in progress[Type] EnhancementA suggestion for improvement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions