Skip to content

isUnmodifiedDefaultBlock returns true if block is missing specified role from attributes #73851

@albanyacademy

Description

@albanyacademy

Description

Relates to #70897 I believe.

I dig this a lot, but it does fail to gracefully handle a default block without a content role assigned anywhere, instead reporting true regardless of any changes.

IMO It should instead fall back to generic isUnmodifiedBlock behaviour if the specified role is not present on the block in question.

Obv simple fix is to just use the content role going forward, but this change definitely caught me flat footed and it took me a while to figure out why the block toolbar was missing from our custom paragraph blocks.

Step-by-step reproduction instructions

  1. create a new dummy block to use as a default without a "role": "content" prop set on any attributes, or just remove the role prop from paragraph block;
  2. inserter always shows, toolbar is missing unless in top toolbar mode

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Feature] InserterThe main way to insert blocks using the + button in the editing interface[Package] Block editor/packages/block-editor[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions