Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
The 'Main page content' block renders even when it is disabled or removed in the block layout.
Steps to reproduce
- Install Drupal
- Create a node with some body content
- Go to
/admin/structure/block/list/bartik
and move the 'Main page content' block into the Sidebar first region - View the node and confirm the page content is appearing in the sidebar
- Go to
/admin/structure/block/list/bartik
and disable the 'Main page content' block - View the node and confirm the page content is appearing in the content region
- Go to
/admin/structure/block/list/bartik
and remove the 'Main page content' block - View the node and confirm the page content is appearing in the content region
Tested in various themes with the same outcome.
Proposed resolution
Respect the settings of the Main content block so that it does not render if disabled or removed.
Remaining tasks
- Agree on an approach
- Write patch
- Review
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A
Comments
Comment #4
pameeela CreditAttribution: pameeela commentedUpdated IS with specific steps.
Comment #5
longwaveThere is specific code to deal with this case in
\Drupal\block\Plugin\DisplayVariant\BlockPageVariant::build()
:I suspect this is by design, because if you remove the main content block, the actual content of the page is missing, and you also might find it hard to reconfigure your site to get the main content block back again.
Is there a use case for not needing the main content block to appear at all?
Comment #6
longwaveActually, this is already discussed elsewhere. Closing as duplicate of #1380858: Main page content block is required and #2546590: Main content block shows up on page, even if hidden
Comment #7
pameeela CreditAttribution: pameeela commented@longwave Nice! Should one of those two also be closed then if they are covering the same issue? I see one has no updates in 7 years :|