Skip to content

Write Mode: Block Movers appear when content block is immediate child of a section #67408

@talldan

Description

@talldan

Description

In Write Mode, blocks are generally divided into three groups:

  • Section blocks: these are blocks near the top level that contain other blocks, they are set to contentOnly block editing mode. They can be moved up and down.
  • Content blocks: these are inner blocks of the sections that are set to contentOnly mode. It shouldn't be possible to move them.
  • Other blocks: blocks that aren't section or content blocks are disabled and unselectable.

For most content blocks that are deeply nested in sections, the block movers don't appear. This is because their parent block is usually set to disabled:

However, if a content block is an immediate child of a section, then the movers do appear due to the parent being set to contentOnly:

The code that governs this is the canMove block selector, the return statement at the end allows movement of a block when the parent is not disabled:

export function canMoveBlock( state, clientId ) {
const attributes = getBlockAttributes( state, clientId );
if ( attributes === null ) {
return true;
}
if ( attributes.lock?.move !== undefined ) {
return ! attributes.lock.move;
}
const rootClientId = getBlockRootClientId( state, clientId );
if ( getTemplateLock( state, rootClientId ) === 'all' ) {
return false;
}
return getBlockEditingMode( state, rootClientId ) !== 'disabled';
}

Step-by-step reproduction instructions

  1. Enable the Write Mode experiment (WP Admin Sidebar > Gutenberg > Experiments)
  2. Switch to Twenty Twenty Four
  3. Insert the 'Hero' pattern into a template
  4. Switch to Write Mode
  5. Select the heading in the pattern, see that there are no block movers
  6. Select the image in the pattern, see that there are block movers

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

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions