Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 305793

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

$
0
0

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 #953034: [meta] Themes improperly check renderable arrays when determining visibility 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.
#953034: [meta] Themes improperly check renderable arrays when determining visibility


Viewing all articles
Browse latest Browse all 305793

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>