I added a block to a region using page manager UI, this block in some pages rendered with this layout has content and in others not, depending of that on my twig template I decide if I render this region with S css class or Y css class. But the regions is coming is always not empty no matters if the only block is empty or not. I checked the panels code and I found

https://cgit.drupalcode.org/panels/tree/src/Plugin/DisplayBuilder/Standa...

 protected function buildRegions(array $regions, array $contexts) {
    $build = [];
    foreach ($regions as $region => $blocks) {
      if (!$blocks) {
        continue;
      }

      $region_name = Html::getClass("block-region-$region");
      $build[$region]['#prefix'] = '<div class="' . $region_name . '">';
      $build[$region]['#suffix'] = '</div>';

this method ALWAYS add the wrapper no matters if is added or not any content to the region.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

meickol created an issue. See original summary.

meickol’s picture

I create this patch, with this the method add the wrappers only if the region has content to show.

Status: Needs review » Needs work

The last submitted patch, 2: region-wrappers-not-always-added-2970834-1.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

meickol’s picture

Assigned: meickol » Unassigned
meickol’s picture

Assigned: Unassigned » meickol
FileSize
516.04 KB

I need help with this I ran the test on my local and all test passed , see screenshot attached

Why the test are no passing here ? thanks.

meickol’s picture

Assigned: meickol » Unassigned
tim.plunkett’s picture

tim.plunkett’s picture

Status: Closed (duplicate) » Needs work

Regardless of that issue this might be a good standalone fix

manuel.adan’s picture

Status: Needs work » Reviewed & tested by the community

PHP 5.5 & MySQL 5.5, D8.4 13 pass,8 fail

Drupal 8.4 is unsupported, so I retest #2 and now it pass with no additional changes:

PHP 5.5 & MySQL 5.5, D8.8 23 pass
PHP 5.5 & MySQL 5.5, D8.6 23 pass

I launched some additional tests along with page_manager that also pass.

manuel.adan’s picture

Status: Reviewed & tested by the community » Needs review
manuel.adan’s picture

Anyway, what is the point of this wrapper? I also simply removed it and tests still pass.