Dashboard: Promote WidgetRender into widget-primitives#78821
Conversation
delegates rendering to widget-primitives' WidgetRender; updates chrome and picker consumers
drop getLazyWidgetComponent and WidgetTypeMetadata from exports; both have no external consumers and stay internal to the kit
fix broken symbol references (WIDGET_NAME_REGEXP, getWidgetTypes) and drop restatement / speculation across README, types, hook, tool and the new WidgetRender component
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 8.21 MB ℹ️ View Unchanged
|
|
Flaky tests detected in a5b627f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26652181688
|
What?
Makes a host-agnostic
<WidgetRender>available fromwidget-primitivesand reduces the dashboard's existingWidgetRenderto a thin adapter (DashboardWidgetRender) that supplies the dashboard-specific bits.Same change also narrows the
widget-primitivespublic API to the symbols its consumers actually use, and trims stale or speculative documentation across the kit.Pure refactor: no behavior change in the dashboard.
Why?
widget-primitivesis positioned as the host-agnostic toolkit for dashboard widgets, but until this PR the code that mounts a widget lived inside the dashboard route. Any future host (a sidebar, an inserter, a future digest area) had to copy the dashboard wrapper to reuse the host-agnostic part.Promoting the host-agnostic render path into
widget-primitivesgives any host a single, canonical entry point. The dashboard wrapper keeps only its host-specific concerns: pulling state fromuseDashboardInternalContext()and dispatching attribute updates against the dashboard layout.In the same pass, the kit's public API is trimmed back to what its consumers (the dashboard host today, and any future host tomorrow) actually need; and a small cluster of doc references that pointed at non-existent symbols or speculated about future tooling is cleaned up.
How?
<WidgetRender>lives atroutes/dashboard/widget-primitives/components/widget-render/and exposes the standard render contract:widgetType,attributes,setAttributes,resolveWidgetModule. Suspense, error handling, and chrome stay host concerns and are not part of the primitive.routes/dashboard/widget-dashboard/components/widget-render/renames its export toDashboardWidgetRender. The wrapper now does two things only: bridge the dashboard context and build the per-instancesetAttributescallback. Consumersdashboard-widget-chromeandwidget-pickerare updated to the new name.widget-primitivesstops exportinggetLazyWidgetComponent(now only consumed by the kit's ownWidgetRender) andWidgetTypeMetadata(no external consumer; widget authors do not annotatewidget.tswith it under the current convention). The package surface is now:<WidgetRender>,useWidgetTypes(), and the contract typesWidgetType,WidgetName,WidgetRenderProps,ResolveWidgetModule.README.md,types.ts, the hook, the tool, and the new component:WIDGET_NAME_REGEXP in registerWidgetType,getWidgetTypesresolver, neither exists; the actual mechanisms areWP_Widget_Type_Registry::register()and theuseWidgetTypeshook).Testing Instructions
Automated coverage: existing JS unit tests in
routes/dashboard/widget-dashboard/test/{widget-dashboard,widget-settings,inserter}.test.tsxpass without code changes, because they consume the contract types fromwidget-primitivesand those are unchanged.Testing Instructions for Keyboard
No UI changes. Existing keyboard behavior in the dashboard and the widget picker is unaffected.