-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Fix setupEditor edits not being applied when non-iterable edits are used
#73167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix setupEditor edits not being applied when non-iterable edits are used
#73167
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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @PaulREnglish! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Good catch, @PaulREnglish! I can confirm the bug; however, the proposed fix doesn't exactly resolve the issue. If we change the arguments for What that condition is trying to check is whether any edit is different from the original post object. I think the problem here is that someone accidentally used This is probably a regression after #35929. diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js
index 81b96e827c..829976b7c1 100644
--- a/packages/editor/src/store/actions.js
+++ b/packages/editor/src/store/actions.js
@@ -62,7 +62,7 @@ export const setupEditor =
}
if (
edits &&
- Object.values( edits ).some(
+ Object.entries( edits ).some(
( [ key, edit ] ) =>
edit !== ( post[ key ]?.raw ?? post[ key ] )
) |
Thanks for taking a look and the detailed explanation! I've reverted my original proposed fix and implemented the |
Mamaduka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing, @PaulREnglish!
What?
No issue number, was easier just to create the PR
Why?
There is a bug with the setupEditor dispatcher. If you pass a non-iterable edit, JS encounters an error preventing the edits from being carried out.
The issue comes from this line:
gutenberg/packages/editor/src/store/actions.js
Line 66 in 0473a54
The parameters of the callback should not be destructured from an array but taken as separate arguments. See the JS documentation.
How?
Remove the square brackets as we should not be using array destructuring for the params.
Testing Instructions
Note that the bug only appears when you pass only non-iterable edits like
nullor numbers. If you include any edits that are iterable, the bug may not appear.Screenshots or screencast
Before
Screen.Capture.on.2025-11-11.at.16-20-36.mp4
After
Screen.Capture.on.2025-11-11.at.16-21-15.mp4