useBlockSync: just testing without isControlled effect#61114
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: -91 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
| if ( ! isControlled ) { | ||
| pendingChanges.current.outgoing = []; | ||
| setControlledBlocks(); | ||
| } |
There was a problem hiding this comment.
So now, I have a vague memory of the Navigation block switching between "not controlled" into "controlled" to support some legacy mode of that block. @draganescu might know more. I guess the testing instructions is to try to load that old navigation block markup in the editor and ensure that everything works as expected.
There was a problem hiding this comment.
The navigation block can start as uncontrolled, when there are navigation inner blocks specified in the markup. When this uncontrolled state is updated by say adding a new navigation link, the content is saved to a CPT and the block switches to controlled.
EDIT:
I tested this PR and the functionality described above seems unaffected.
There was a problem hiding this comment.
But the potentialy buggy part is when you hit Undo after this switch from uncontrolled to controlled. Then probably the navigation block should switch back to uncontrolled? And revert to the uncontrolled inner blocks specified in the markup?
That's what the title of #37484 (the PR that claims to fix #37361) says: "avoid undo issues"
There was a problem hiding this comment.
the navigation block should switch back to uncontrolled?
I can't tell if that was ever the case? I don't even know if we want that, the uncontrolled version is just a way for themes to include default navigation content for style reasons.
|
So the PR that introduced this fixed #37361. I tried to reproduce the original issue, but maybe I'm doing it wrong. Edited the page content, then undo, but the header template contents are still there. Unfortunately there's no e2e test I think. |
jsnajdr
left a comment
There was a problem hiding this comment.
Yes, IMO the effect is guaranteed to never be called. The only place where isControlled can go from true to false is the cleanup effect function of useBlockSync, when the hook is unmounting. And at that time of unmounting and cleanup, no new effect will be scheduled.
|
Whoops, forgot to change the commit title 🤦♀️ |
What?
Just checking what tests will fail, see #60967 (review)
Edit: ok, this passed 🙂
Edit: but it was first introduced in #37484 (fixing #37361), which didn't add any e2e tests. So we'll have to check that.
Why?
Reduce complexity
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast