Repository navigation
Conversation
wp-build copies it into the registry; the registration gate keeps JSON attributes
the module example wins; the record stands in when it declares none
the widget ships without a metadata module
🤖 PR meta 🤖📦 Bundle sizeSize Change: +22 B (0%) Total Size: 9.05 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Regression: updating a specific option will only change its value and will not corrupt others in
|
retrofox
force-pushed
the
update/widget-json-example
branch
from
October 20, 2026 22:52
efe2597 to
e2c3df7
Compare
icon and actions fields, source extensions, style module, name in widget.json, module-less records
the type carries the manifest's declarative metadata, not only name and module handles
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
widget.jsoncan now declareexample, with the shape of the runtime field ({ "attributes": { … } }), and it travels through the build manifest, the server registry, the REST record anduseWidgetTypes. Hello World moves its example there and drops its metadata module.Closes #85170
Why
exampleis what hosts preview a widget type with and what a new instance starts from, and it was the last field only awidget.tscould declare. Most examples are plain data, so widgets kept a module for one JSON literal.How
packages/wp-build/lib/build.mjs
toPhpExampleLiteral()copiesexampleintobuild/widgets/registry.phpnext toattributes, asnullunless it carries a non-emptyattributesobject.lib/experimental/dashboard-widgets/widget-types.php
gutenberg_sanitize_widget_example()gates registration:attributesstays a map of attribute names to JSON data (checked recursively bygutenberg_is_widget_json_value()), other keys and non-serializable attributes drop, and an empty result becomesnull. Example values are data, so nothing is translated.lib/experimental/dashboard-widgets/class-wp-rest-widget-modules-controller.php Exposes
exampleand declares it in the schema asobject|null. A nested empty object still reaches the client as[], as withblock.jsonexamples; the top-level map always encodes as an object.packages/widget-primitives/src/hooks/use-widget-types.ts A record without a metadata module takes
examplefrom the record. With a module, the module'sexamplewins and the record's stands in only when the module declares none.WidgetModuleRecord.examplecarries the wire form.widgets/hello-world
examplemoves intowidget.jsonandwidget.tsgoes away.docs/explanations/architecture/dashboard-widgets.md, packages/wp-build/README.md Document the field and the module-wins rule. The README also catches up with drift unrelated to
example:iconandactionsin the field list, the source extensions the build accepts,style.module.css, andnameliving inwidget.json. The architecture doc feeds the System Architecture story.Testing
npm run buildand checkbuild/widgets/registry.php:core/hello-worldcarries'example' => array( 'attributes' => array( 'message' => 'Hello World' ) )and'has_widget' => false.gutenberg-dashboard-widgetsexperiment on,GET /wp/v2/widget-modules/core/hello-worldreturns"example": { "attributes": { "message": "Hello World" } }and"widget_module": null.Follow-ups
exampleto thewidget.jsonJSON Schema tracked in Addwidget.jsonmetadata schema #77629.