-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Refactor reusable blocks and editor effects to action-generators using controls (core/editor data store) #14491
Conversation
'core/block-editor', | ||
'receiveBlocks', | ||
[ parsedBlock ] | ||
); |
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.
Note, the above two dispatches (replaceBlocks
and receiveBlocks
) used to be _after the _experimentalSaveReusableBlock
dispatch in the effects. However in testing after the conversion the reusable block conversion failed because the block wouldn't actually get replaced. I suspect this worked with effects because the timing worked a bit differently there. Switching these around works okay.
@aduth since you reviewed the previous refactor in this package I included you for reviewers as well. This has the potential to go stale quickly so getting it merged in sooner would be ace. |
I'm investigating the e2e fails, on the surface they look legit. |
Pretty crazy, I'm reproducing the e2e fail. Selecting multiple blocks and then clicking to convert to reusable blocks completely locks up the view! No errors in the console, just inability to interact with the view. Closing the tab is not possible as well. Going to try and nail down what's happening. |
So it looks like its related to the switch in dispatch order I added. |
So here's what happens if I restore the dispatches: yield dispatch(
'core/block-editor',
'replaceBlocks',
clientIds,
createBlock( 'core/block', { ref: reusableBlock.id } )
);
// Re-add the original block to the store, since replaceBlock() will have removed it
yield dispatch(
'core/block-editor',
'receiveBlocks',
[ parsedBlock ]
); So they are after the The reusable block saves, but the subsequent If I, put the actions before (as they are currently in this branch) then SINGLE blocks convert to reusable blocks with no issues, but multiple selected blocks cause the browser to crash. I'll still investigate but just posting my findings so far because so far its stumping me. |
I think it may be related to
At the time this is invoked (via the |
Noting: Is this perhaps in conflict with #14367, which would otherwise deprecate (or work toward deprecating) most of the dedicated reusable blocks handlers? I'll plan to circle back to take a closer look. |
I think it's definitely related and I was semi aware of that pull. There's still not a whole lot removed I think from |
Related: #13088 (comment) I think ultimately neither should have too much awareness of how to deal with them.
|
Is there any of this which can be extracted into smaller pull requests? |
It's made it clear to me that the refactor is far overdue, as the aggregate of technical debt in managing reusable blocks has made it exceedingly difficult to follow (particularly with the new fragmentation between Framed more productively, I wonder if we can't consider:
I think it may also be worth getting some alignment on where and how we see "reusable blocks" existing as a thing in our implementations. I touched on this in #14491 (comment) , but in looking more at #14367 , I think I might not be seeing it quite the same as others. I'd have thought we should be able to eliminate almost all occurrences of the keyword "reusable" in the code of I'd like to revisit this tomorrow with a fresher mind. |
ya agreed.
Yup agreed I'll do in a separate pull.
Ya I would agree here as well. One thing that I noticed while doing this is that the block post type is repeatedly fetched via rest api in the
Hmm, ya that's interesting. I admittedly haven't dove to much into reusable blocks but it is apparent its in a very unstable state (likely due to evolution over time) and as referenced by all the |
3c8dbdf
to
2044d4c
Compare
setupEditor refactor moved to #14513 |
I'm going to close this pull because it's quite out of date and I think refactors have been ongoing as code is changed. I refreshed #14594 which is ready to merge. |
Description
This completes the refactor of effects to action-generator for the
core/editor
package. The changes here are pretty straightforward and preserve the behaviour in the original effects.How has this been tested?
Checklist:
General note
One thing I noticed when working on this refactor is that it's not immediately clear what the difference is between reusable block behaviour in the
core/block-editor
store/package and reusable block behaviour in thecore/editor
store/package. I realize that thecore/block-editor
package was created as a part of the ongoing work to make it possible to have standalone block editors apart from the post editor view. However, I didn't find any documentation for devs to know the distinction between the two. I suspect this is in part because this work is still in transition, but for future development it'd be useful to have something clarity outlined in thecore/block-editor
documentation about the state it maintains and what criteria is used for state maintained in it.