Problem/Motivation
Since v2.0.4, we have error on components library if stories use theme: item_list in slots
Error in the navigator :
Le site Web a rencontré une erreur inattendue.
InvalidArgumentException: "type" is an invalid render array key. Value should be an array but got a string. in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).
template_preprocess_item_list()
call_user_func_array() (Line: 261)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 150)
__TwigTemplate_41d3604099f154c0e6341b63440d4563->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 358)
Twig\Template->display() (Line: 373)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 1520)
Twig\Extension\CoreExtension::include() (Line: 50)
__TwigTemplate_b902fea1f050b54add1f8ee51323e00b->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 141)
__TwigTemplate_6f5ea93c11b10e81d5186d1765b7bc8a___412906545->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 44)
__TwigTemplate_6f5ea93c11b10e81d5186d1765b7bc8a->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 358)
Twig\Template->display() (Line: 373)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 234)
Drupal\Core\Template\TwigEnvironment->renderInline() (Line: 54)
Drupal\Core\Render\Element\InlineTemplate::preRenderInlineTemplate()
[...]
Steps to reproduce
-
Use
theme: item_list in the content of a slot in component story
Example :
name: Preview
slots:
content:
- theme: item_list
list_type: ul
items:
- type: html_tag
tag: p
value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'
-
Open your components library in navigator (/admin/appearance/ui/components)
Proposed resolution
Looking at the content of 2.1.4 release (https://www.drupal.org/project/ui_patterns/releases/2.0.4) it seem to be related to https://www.drupal.org/project/ui_patterns/issues/3515500
The bug also concerns UI examples V1.0.2
Our temporary solution is to prefix items content with #
For example :
- type: html_tag
tag: p
value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'
became :
- '#type': html_tag
'#tag': p
'#value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ...'
Comments
Comment #2
malikah commentedComment #3
pdureau commentedyour example is an incorrect YAML snippet:
I guess you meant this:
item_listis not a render child but a render property. Each item expects:Source: https://api.drupal.org/api/drupal/core%21modules%21system%21templates%21...
So, i guess you need to do this:
Is it OK like that?
Comment #4
malikah commentedThank you pdureau for your feedback and I apologize for this late answer.
You're right, I actually made an indentation mistake in my previous example.
As you suggested, I've try with :
But the error in the navigator is similar :
Comment #5
smovs commentedComment #6
pdureau commentedIf we have fix, let's also port it to "UI Examples" module (which share some logic with "UI Patterns Library")
Comment #8
grimreaperFixed provided on ui_examples #3529189: Using item_list in examples break rendering.
Please port the fix here.
Comment #11
anmolgoyal74 commentedComment #12
pdureau commentedComment #14
just_like_good_vibesComment #16
just_like_good_vibes