Views blocks now use placeholders, making it impossible for the theme to determine if it’s empty or not

Created on 2 July 2025, 4 days ago

Problem/Motivation

Since updating to 11.2.2 we have noticed that this code in ViewsBlockBase.php has created an issue:

  /**
   * {@inheritdoc}
   */
  public function createPlaceholder(): bool {
    return TRUE;
  }

Our issue involves a Views block, where in our twig file we are using the following filters:

render|striptags|trim|length > 0

to evaluate whether anything is to be rendered and thus render the surrounding markup to contain it. However after this addition was made the render filter now produces a <drupal-render-placeholder> element alone, so once the striptags filter is ran on that then we are left with nothing. Thus our check above evaluates to false, and our views block does not get rendered to the page even though it contains results.

If I alter the createPlaceholder() method to return FALSE then our Views block is once again rendered as expected.

Steps to reproduce

  1. Create a Views block that contains output (I believe just a title will suffice)
  2. Place the block in a region
  3. In a twig template, use the above filters on the region to see the placeholder element alone
  4. Alter the createPlaceholder() method to return FALSE
  5. Observe that the above filters now work as there is markup left after they are passed through.
πŸ› Bug report
Status

Active

Version

11.2 πŸ”₯

Component

views.module

Created by

πŸ‡¬πŸ‡§United Kingdom jonnyhocks

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024