-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Preserve controlled inner blocks on RESET_BLOCKS #61524
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: -21 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
What guarantees that the clientIDs of the new blocks are still "controlled"? |
First I assume that the If the new version of the block doesn't want to be controlled, it will signal that by not mounting In short, the controlled state is now controlled solely by Until now not everything was under |
That makes sense, in my understanding this PR was removing the "cleanup" from useBlockSync while useBlockSync is the only place that knows for sure whether a block is controlled or not. As for the clientId, for me we can't really assume that a clientId refers to the same block after you call RESET_BLOCKS but this is fine as long as useBlockSync is responsible for cleaning things up. |
Yes: even if
The old implementation didn't have this inconsistent "new block with old controlled children" state. Instead, if both the old and new block were of the same type and both wanted to be controlled (canonical example of such a reset is an undo that changes only other blocks), the block became briefly uncontrolled, with uncontrolled inner blocks. |
Experiment inspired by #61480.
RESET_BLOCKS
action destroys thecontrolledInnerBlocks
state and also doesn't carry over the info about controlled inner blocks.useBlockSync
then needs special code to quickly recover the controlled state and to set the controller inner blocks again.This PR attempts to improve the
RESET_BLOCKS
action so that the controlled blocks state is carried over. That means:state.controlledInnerBlocks
is preserved, and we continue to know that a block with certainclientId
should be controlled.state.attributes
,state.byClientId
, ...) for controlled inner blocks is preserved. Previously only the state for the new blocks and their uncontrolled children (innerBlocks
) was part of the new state, the rest was forgotten.state.order
contains the controlled blocks, it's not reset to uncontrolled. These are still instate.tree
, and will be written tostate.order
if the block switches to uncontrolled mode.Let's see how this fares with the e2e tests.
Currently the
RESET_BLOCKS
reducer carries over too much info: it keeps everything that was in the previous state, and only adds info fromaction.blocks
. This is harmless, but inefficient. If the experiment proves viable, I'll improve the code to carry over only the old controlled blocks + new blocks fromaction.blocks
.