I created a menu named Header with machine name of header. When I placed the block into a region of the same name (header), the region is no longer listed in the UI. The block does get placed, and the block's region dropdown shows being set to Header. Screenshot attached of block UI. Deleting the block causes the Header region to show in the UI again.

Steps to reproduce:

  • Create a block with machine name of "header" ( Menus and Custom blocks both produce the behavior)
  • Place block in Block UI, adding it to "header" region

Expected Behavior:
Block is placed and shows in "header" region in UI.

What happened instead:
Block gets placed in header region, but header region disappears from Block UI.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because the UI can break under certain circumstances
Issue priority Normal because the UI is still functional and it doesn't affect runtime
Disruption Not disruptive because no real changes.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Version: 8.0.0-beta11 » 8.0.x-dev
Assigned: Unassigned » tim.plunkett

I was able to reproduce. Taking a look into this.

tim.plunkett’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
21.34 KB

Still needs tests. I had to refactor a bit to track down the bug.

tim.plunkett’s picture

Issue tags: -Needs tests
FileSize
788 bytes
22.11 KB

Here's a test.

tim.plunkett’s picture

Issue summary: View changes
FileSize
73.74 KB

Also note, it not only removes the region name, it incorrectly puts the faulty block into that section of the page.

The last submitted patch, 3: 2508547-block-3-FAIL.patch, failed testing.

tim.plunkett’s picture

Title: Placing a block with same machine name of region causes region to disappear in UI » Placing a block with same machine name of region causes region to disappear in admin UI

The title makes this sound like a MUCH bigger problem, hah.

tim.plunkett’s picture

FileSize
21.31 KB
303 bytes

hook_rebuild() doesn't return anything.

Postponed #2513534: Remove the 'disabled' region from Block UI on this bug fix, since it refactors the block UI code.

tim.plunkett’s picture

Issue summary: View changes
neclimdul’s picture

Status: Needs review » Reviewed & tested by the community

Lots of good refactoring. Tried really hard to find a mistake in it but the one I thought I found in block_rebuild even turned out to just be cleanup.

+++ b/core/modules/block/src/BlockListBuilder.php
@@ -192,36 +179,63 @@ public function buildForm(array $form, FormStateInterface $form_state) {
-      $form['blocks'][$region] = array(
+      $form['region-' . $region] = array(
...
-      $form['blocks'][$region]['title'] = array(
...
+      $form['region-' . $region]['title'] = array(
...
-      $form['blocks'][$region . '-message'] = array(
+      $form['region-' . $region . '-message'] = array(

@@ -230,8 +244,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
-      $form['blocks'][$region . '-message']['message'] = array(
...
+      $form['region-' . $region . '-message']['message'] = array(

The fix. Prefixing the form element so it doesn't collide.

tim.plunkett’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
FileSize
2.34 KB

Okay I got called out for the scope creep. Opening another issue to do the refactoring.
Also we lost the test coverage somewhere.

tim.plunkett’s picture

neclimdul’s picture

Status: Needs review » Reviewed & tested by the community

back to rtbc

jibran’s picture

RTBC +1

Wim Leers’s picture

What an amazing bug btw! :D

  • xjm committed 760cd40 on 8.0.x
    Issue #2508547 by tim.plunkett, tannerjfco, neclimdul: Placing a block...
xjm’s picture

Priority: Normal » Major
Status: Reviewed & tested by the community » Fixed

This is delightful. Bumped to major as someone who encountered this on a site would have no clue what was going on.

I manually tested to double-check that the change to the form structure is not linked into block entity configuration (in order to confirm that there is no data model change and no update path needed).

This issue is a major bug fix, and the only disruption is in changing the array structure of the block form, so it is allowed per https://www.drupal.org/core/beta-changes.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.