-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Recent efforts around Zoom Out and "Content Only" Select Mode have put more focus on the concept of the "Section Root".
The "Section Root" is loosely defined as the block which represents the "main content" of the post/page/template you are working on. It is the parent of all the "sections" of the post.
The current algorithm used to detect this is:
gutenberg/packages/editor/src/components/provider/use-block-editor-settings.js
Lines 149 to 160 in 524516d
| function getSectionRootBlock() { | |
| if ( renderingMode === 'template-locked' ) { | |
| return getBlocksByName( 'core/post-content' )?.[ 0 ] ?? ''; | |
| } | |
| return ( | |
| getBlocksByName( 'core/group' ).find( | |
| ( clientId ) => | |
| getBlockAttributes( clientId )?.tagName === 'main' | |
| ) ?? '' | |
| ); | |
| } |
It considers:
core/post-contentif it's a page- the
<main>tag for anything else
As not all Themes/Sites will use a standard setup (arrange of blocks, usage of tags...etc) we should try and make small improvements that capture some of the most common cases.
We can not (and should not) try to capture every possible use case, because that will be impossible.
The features that make use of the "section root" are:
- Zoom Out mode
- Proposed changes to other modes
Todo
We need some concrete examples of edge cases around detecting the “section root” in the Editor.
For example some folks mentioned some Themes are throwing a wrapping div around things or not using <main>…etc. We need to gather some specifics.
Pinging @WordPress/gutenberg-design
Examples
[Please list examples below]