Problem/Motivation

The 'Main page content' block renders even when it is disabled or removed in the block layout.

Steps to reproduce

  1. Install Drupal
  2. Create a node with some body content
  3. Go to /admin/structure/block/list/bartik and move the 'Main page content' block into the Sidebar first region
  4. View the node and confirm the page content is appearing in the sidebar
  5. Go to /admin/structure/block/list/bartik and disable the 'Main page content' block
  6. View the node and confirm the page content is appearing in the content region
  7. Go to /admin/structure/block/list/bartik and remove the 'Main page content' block
  8. 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

  1. Agree on an approach
  2. Write patch
  3. Review

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Comments

Alex72RM created an issue. See original summary.

Version: 8.1.0 » 8.1.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.1.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Title: main page content block always visible even if disabled » Main page content block visible even if disabled or removed
Version: 8.9.x-dev » 9.1.x-dev
Issue summary: View changes
Issue tags: +Bug Smash Initiative

Updated IS with specific steps.

longwave’s picture

There is specific code to deal with this case in \Drupal\block\Plugin\DisplayVariant\BlockPageVariant::build():

    // If no block that shows the main content is displayed, still show the main
    // content. Otherwise the end user will see all displayed blocks, but not
    // the main content they came for.
    if (!$main_content_block_displayed) {
      $build['content']['system_main'] = $this->mainContent;
    }

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?

longwave’s picture

Status: Active » Closed (duplicate)

Actually, 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

pameeela’s picture

@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 :|