use same behavior as Gutenberg web for replacing an empty default block #338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Comes from #327 (comment)
While PR #327 addresses #315 description, it's been observed that desired behavior is more that of following along Gutenberg web as much as we can. @koke observed the behavior should be closer to Gutenberg's by using
isUnmodifiedDefaultBlock
(see https://github.com/WordPress/gutenberg/blob/40d1282a992702e1933118ef626f0666692baf2b/packages/editor/src/components/inserter/menu.js#L389)Please note that this makes the default block (currently,
core/paragraph
) the only block type eligible for replacement when such a block is both empty and selected, and the user taps on + to bring up the inserter's block picker.With this PR then, if the user is standing on an empty
Heading
orCode
block, they won't be able to replace such blocks anymore - the user will only be able to replace a block if they're standing on aParagraph
empty block.I tested this on Gutenberg web and could observe the same.
To test: (paragraph)
To test: (other editables, non-paragraph)
Try steps 8-10 again, inserting a new block while standing on a Code block instead of Title (Heading), and observe in both cases the new block is appended (or inserted below the selected block) rather than replace the previously selected block.