False positive when checking empty slots

Created on 10 May 2025, 4 days ago

Problem/Motivation

In UI Suite Bootstrap, in the table component, there is:

  {% if caption %}
    <caption>{{ caption }}</caption>
  {% endif %}

The table presenter template is passing an empty string as the caption variable.

But in the component template I have an array with an empty #children.

In ui_patterns/src/Plugin/UiPatterns/PropType/SlotPropType.php, there are 2 problematic places :

    if (is_string($value)) {
      return ['#children' => Markup::create($value)];
    }

After making the proposed change I obtain an empty array with #cache from:

protected static function cleanRenderArray(array $value): mixed {
    if (empty($value)) {
      // Element::isRenderArray() returns FALSE for empty arrays.
      return ['#cache' => []];
    }

Steps to reproduce

Using UI Suite Bootstrap, create a View using a table display.

Proposed resolution

    if (is_string($value) && !empty($value)) {
      return ['#children' => Markup::create($value)];
    }

I don't know what to do about the other place where there is a problem.

Remaining tasks

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

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

Comments & Activities

Production build 0.71.5 2024