You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Editing post in Text Mode causes shared blocks to go away #5754
If you edit a post using Text Mode, any shared blocks will appear as though they have been deleted when you return to Visual Mode.
Steps to Reproduce (for bugs)
Create a new post
Create or insert a Shared Block
Switch to Text Mode
Make an edit, e.g. add a line of text
Return to Visual Mode
Expected Behavior
The Shared Block should render properly in the visual editor.
Current Behavior
The Shared Block appears as though it has been deleted.
Possible Solution
This is because RESET_BLOCKS is dispatched when PostTextEditor is blurred. This has the unintended side effect of deleting the block that the Shared Block is referencing.
One solution is to change RESET_BLOCKS so that it doesn't delete any blocks in blocksByUid that are referenced by orderedBlocks or reusableBlocks.
Yes we will need to fix this. Note that it's up to the release lead whether or not #7453 will be punted. Right now, it's still in the 5.0 milestone.
For me this is an incredibly annoying issue since my only plan atm for templating involves using e.g. an 3rd party section block or a hacky 1 column column block to store a bunch of blocks as a reusable block (and to convert that to a regular block after importing the ”template”)
If I'm understanding you correctly, #9732 which was shipped in Gutenberg 3.9 should let you turn multiple blocks into a single reusable block.
This is because RESET_BLOCKS is dispatched when PostTextEditor is blurred. This has the unintended side effect of deleting the block that the Shared Block is referencing.
One solution is to change RESET_BLOCKS so that it doesn't delete any blocks in blocksByUid that are referenced by orderedBlocks or reusableBlocks.
This still holds true and is a little tricky to address. Some ideas:
Mark reusable blocks in blocksByClientId with a flag e.g. isReusable: true. Then, RESET_BLOCKS could ignore blocks that have the isReusable flag set. getBlock could strip this flag out so that there isn't any extra API which we have to maintain.
Activity
noisysocks commentedon Jul 11, 2018
#7453 (or any similar refactor of how we implement shared blocks) will likely fix this.
dkieffer commentedon Sep 10, 2018
@slimmilkduds my current workaround until this is fixed is creating custom html reusable blocks.
dkieffer commentedon Sep 13, 2018
@slimmilkduds add a custom html block, make some sections or divs or whatever, then convert it to a reusable block.

noisysocks commentedon Oct 29, 2018
Yes we will need to fix this. Note that it's up to the release lead whether or not #7453 will be punted. Right now, it's still in the 5.0 milestone.
If I'm understanding you correctly, #9732 which was shipped in Gutenberg 3.9 should let you turn multiple blocks into a single reusable block.
noisysocks commentedon Oct 29, 2018
Thanks for the clarification @slimmilkduds! I'll look into getting a quicker albeit less ideal fix in for these two bugs 🙂
noisysocks commentedon Oct 30, 2018
This still holds true and is a little tricky to address. Some ideas:
blocksByClientIdandorderedBlocksare removed in lieu of ablocksobject with abyClientIdandordersubtrees. Then,RESET_BLOCKScould ignore blocks that are present in the.ordersubtree. @aduth also did this as part of Editor: Reshape editor state for optimized and accurate dirtiness detection #10844.blocksByClientIdwith a flag e.g.isReusable: true. Then,RESET_BLOCKScould ignore blocks that have theisReusableflag set.getBlockcould strip this flag out so that there isn't any extra API which we have to maintain.