Block Editor: Reusable blocks fetching causes "Unsaved Changes" prompt #14910
Labels
[Feature] Synced Patterns
Related to synced patterns (formerly reusable blocks)
[Package] Block editor
/packages/block-editor
[Package] Editor
/packages/editor
[Priority] High
Used to indicate top priority items that need quick attention
[Type] Bug
An existing feature does not function as intended
Related: #14766
Describe the bug
Any action which triggers reusable blocks to become fetched will trigger the editor's mechanism to prompt the user when they leave the page.
This includes:
To reproduce
Or:
Or:
Expected behavior
A prompt should not be shown.
Additional context
There is a fair amount of debugging information available at:
Specifically, the comment at #14766 (comment) describe that the reason this occurs is that when the block editor receives reusable blocks as a result of the fetch, it considers this a change in its own state, which surfaces up to the editor and is accounted for in considering to show the prompt upon leaving the page.
It is not easy to solve because:
RECEIVE_BLOCKS
may in-fact include dirtying changes, so it cannot be skipped for consideration in whether the BlockEditorProvider call theonInput
oronChange
props.select( 'core/block-editor' ).getBlock
).Ultimately this ties into the issues of #7119 and related explorations at #14367 and #14715 , where the block editor state is not responsible for holding data of the reusable blocks. These however are much larger tasks, and a more immediate fix should be explored.
I am currently considering a fix which would update the blocks autocompleter to trigger the reusable blocks fetch only when generating its own options. However, as noted above, this only accounts for one of three possible workflows to trigger reusable blocsk fetching.
cc @youknowriad in case you have thoughts.
The text was updated successfully, but these errors were encountered: