Dashboard: Fix Add widget error on non-secure HTTP origins#78850
Conversation
Replace crypto.randomUUID() with the uuid package so widget creation works when the dashboard is served over HTTP on non-localhost domains. Co-authored-by: Cursor <[email protected]>
|
Size Change: 0 B Total Size: 8.21 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 95e0b3d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26748639738
|
There was a problem hiding this comment.
Same as #76151 👍 and aligns with what we do in blocks
|
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. |
What
crypto.randomUUID()withuuidv4 increateDashboardWidget()when stamping new widget instance IDs.uuid(^14.0.0) as a dependency ofroutes/dashboard, matching other Gutenberg packages.Why
crypto.randomUUID()is only available in secure contexts (HTTPS,localhost, etc.). On plainhttp://origins—common in local development—clicking Add widget throws and the inserter fails.How
v4 as uuidfrom theuuidpackage increate-dashboard-widget.ts.uuid()instead ofcrypto.randomUUID()when creating a newDashboardWidgetinstance.routes/dashboard/package.jsonand updatepackage-lock.json.Test plan
http://(non-localhost) site, open the dashboard and add a widget via the inserter — no console error, widget appears in the layout.localhost, confirm adding widgets still works.npm run test:unit routes/dashboard/widget-dashboard/test/create-dashboard-widget.test.tsstamps the type name and a unique uuid).