Umami theme ignores placeholders and HTML replaced elements when checking for empty regions

Created on 18 January 2018, over 6 years ago
Updated 26 May 2023, about 1 year ago

Problem/Motivation

Currently, the Umami theme checks for empty regions by doing this:

 {% if page.header|render|striptags|trim is not empty %}

The idea behind using the striptags filter is that it would leave any plain text content produced by blocks and thus show regions that are not empty.

But the striptags filter also removes HTML replaced elements such as img, video, iframe, audio, canvas, etc. That filter also removes Drupal's <drupal-render-placeholder> used by Big Pipe.

That means the current code removes A LOT of valid content. If Umami were a regular theme (and not a demo theme for a specific set of demo content), this would be a major bug.

Because of the stripped content, this is NOT a duplicate of 🌱 [meta] Themes improperly check renderable arrays when determining visibility Needs work but that issue is definitely related.

Steps to reproduce

TODO: Document how to see this bug with the Umami content. Do we need to add additional content? Or is it visible right out of the box?

Proposed resolution

Patch in #35 reworks the page template so that we don't need to do the if checks. Any thoughts on this approach?

User interface changes

Patch in #35 adds some new wrapper divs.

API changes

TBD

Data model changes

None

Release notes snippet

TBD

Original report

From issue:
==============
+++ b/core/profiles/demo_umami/themes/umami/templates/layout/page.html.twig
@@ -0,0 +1,132 @@
+ {% if page.header|render|striptags|trim is not empty %}
...
+ {% if page.tabs|render|striptags|trim is not empty %}
...
+ {% if page.banner_top|render|striptags|trim is not empty %}
...
+ {% if page.breadcrumbs|render|striptags|trim is not empty %}
...
+ {% if page.page_title|render|striptags|trim is not empty %}
...
+ {% if page.sidebar|render|striptags|trim is not empty %}
...
+ {% if page.footer|render|striptags|trim is not empty %}
...
+ {% if page.bottom|render|striptags|trim is not empty %}

Is this the only way we can do this? Surely we can do something smarter in preprocessing?
==============

If we just print

{% if page.tabs %}
{{ pagetabs }}
{% endif %}

We get empty regions printed on every page that there is no block in that region for. So on a views page, we'll have <div class="region-tabs"></div>

This is a known issue in Drupal core, so we can't fix it until that is fixed.
🌱 [meta] Themes improperly check renderable arrays when determining visibility Needs work

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Umami 

Last updated 9 days ago

Created by

🇮🇪Ireland markconroy

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024