Edit Post: Hoist setupEditor to run before root.render#78581
Conversation
|
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: +9 B (0%) Total Size: 8.04 MB 📦 View Changed
ℹ️ View Unchanged
|
99ad17b to
37ab097
Compare
Dispatch \`editor/setupEditor\` synchronously in the post-editor kickoff (after preloadedResolutions settles, before \`root.render\`). The post record is already in core-data by then, so reading it synchronously and dispatching from there sets \`state.postId\` / \`state.postType\` ahead of React mount. This means Layout's first render — and \`__unstableIsEditorReady\` — already reflect the loaded post, removing a post-commit re-render where the editor flipped from \"not ready\" to \"ready\" once \`<EditorProvider>\`'s \`useLayoutEffect\` got to dispatching \`setupEditor\` itself. \`<EditorProvider>\` still dispatches \`setupEditor\` in its own \`useLayoutEffect\` — that stays as the canonical setup path, and the second dispatch is idempotent for existing posts (the only extra work would be for an auto-draft with a template, which dispatches a block reset; if that matters in practice we can guard it later). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…t kickoff Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37ab097 to
acbc7c5
Compare
|
Flaky tests detected in acbc7c5. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26298700962
|
Calls setupEditor() before mounting the editor in React, reducing the re-renders from 3 to 1 on mount.