- Issue created by @Grimreaper
- πΊπ¦Ukraine SmovS Lutsk
Hi @grimreaper
I have added a check for a non-empty value according to your proposal.But I'm still confused about this false positive when checking slots.
E.g. I set the caption in the table with wysiwig source with an empty textarea.In this case, the table contains an empty caption tag because wysiwig source creates an array with text format settings.
It would be cleaned by self::cleanRenderArray(), but didn'tI am not sure if it is related to the false positive that you mentioned. Probably I went the wrong way.
- π«π·France Grimreaper France π«π·
Hi @smovs,
The problem occurs for example when using the table component with the views table presenter template.
If you are using a component "manually" or with site building it is ok.
But with a presenter template, like written in the issue summary, you can get an empty string as slot value and in this case the problem occurs.
So, to test you can create a view using the table display (not component display using the table component).
- πΊπ¦Ukraine SmovS Lutsk
Hi @grimreaper
Sorry for the delay.
What I found.
From my point of view, rendering works as expected in general, because:
When we check if$value
is empty and set it['#cache' => []]
, we create a non-empty array. It means we redefine the variable from non-array to array in this case. SeeSlotPropType::normalize
if (!is_array($value)) { return empty($value) ? ['#cache' => []] : ['#plain_text' => (string) $value]; }
In Twig template, when we check
{% if caption %}
is always true because in this case, we pass a non-empty array.I am not fully understanding the purpose of the forced setting
['#cache' => []]
each time.I added screenshots for better understanding