Issue as outlined in https://www.drupal.org/node/2443457 is in regression.

As requested by @dawehner I'm opening a new issue instead of re-opening the old one.

There on the old issue there are 2 people posts outlining they're having the same problem, and with myself that makes 3.

Here is @didaka 's steps to reproduce.

I have just faced this issue again in Drupal 8.0.2.

Steps to replicate on a boilerplate Drupal 8.0.2. with Bartik on simplytest.me:

Create a view with a block that accepts nid as default argument from url.
Add argument validation that hides the view. Basic validation will be enough.
Set "Hide block if the view output is empty: Yes"
Display the block in the empty sidebar_second (Left sidebar) on Bartik.
Create an article node. The secondary sidebar should show the node title.
Go to frontpage. The secondary sidebar is rendered, but empty. Body classes are also added.

I can confirm this happens in Drupal 8.0.5

Comments

afoster created an issue. See original summary.

lendude’s picture

Title: Regression - Views block displayed when no results returned » Empty region rendered when a Views block with no results and 'block_hide_empty' set is in the region
Status: Active » Needs review
StatusFileSize
new1.5 KB

Hmm I'm not sure if this is a Views issue or a page layout issue. The block isn't rendered at all, so the 'block_hide_empty' works as advertised. But the page thinks something will be rendered, so the region is rendered (and then turns out to be empty).

Adding a test to illustrate the problem, but again, not sure if Views is the right place to test or fix this.

lendude’s picture

Oh and any empty Views block will make this happen.

So making a block showing content filtered on a content type that has no nodes works just as well as the steps outlined in the issue summary.

Status: Needs review » Needs work

The last submitted patch, 2: empty_region_rendered-2685157-2-TEST_ONLY.patch, failed testing.

lendude’s picture

Hmm looking at it more this just seems like a duplicate/symptom of #953034: [meta] Themes improperly check renderable arrays when determining visibility.

3eidoz’s picture

I'm having the same issue in D8.0.5

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

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

wim leers’s picture

#5: indeed.

m.zerres’s picture

I have the same issue with a menu block i.e. in the first sidebar. Even it is empty the following code is rendered:

<aside class="col-sm-3" role="complementary">
</aside>

This happens in Bartik

m.zerres’s picture

Component: views.module » menu.module
3eidoz’s picture

still in D8.1.3

lendude’s picture

Component: menu.module » views.module
Status: Needs work » Closed (duplicate)
Parent issue: » #953034: [meta] Themes improperly check renderable arrays when determining visibility

Closing this as a duplicate of #953034: [meta] Themes improperly check renderable arrays when determining visibility, this has nothing to do with Views or Menu, but only with placeholders for dynamic blocks (which Views and Menus tend to be).

jwilson3’s picture

Cross-post from #2443457. Just following up here that the current workaround until a solution to #953034: [meta] Themes improperly check renderable arrays when determining visibility lands is to render the output of the region the block is placed in to determine whether to render the region.

Eg. in page.html.twig in your theme:

{# render and strip out everything except images, iframes, objects and svgs that don't have any inner html #}
{% set has_sidebar_right = page.sidebar_right|render|striptags('<img><iframe><object><svg>')|trim|length %}

...

{% if has_sidebar_right %}
  {{ page.sidebar_right }}
{% endif %}

...