Problem/Motivation
I use ui_suite_dsfr 1.1.x with ui_patterns:2.x
In twig, i call the pattern tile without giving border props. According to component definition, border default value is TRUE, but this default value is never given to tile.twig.
My twig file :
{{ include('ui_suite_dsfr:tile', {
variant: 'horizontal',
image : content.field_icon ,
title : content.title,
icon: paragraph.field_tile_display_icon.value
}, with_context = false) }}
Steps to reproduce
Call a pattern from twig without passing a prop which is defined with default value.
Proposed resolution
Take care of props defaults values.
Remaining tasks
- Fix
- Create test
User interface changes
If some implementation of patterns in twig didn't declare props which have default value, display could be affected.
Example : in tile (for ui_suite_dsfr), border is default to true. After fixing this issue, implementation of the tile without defining border props will display borders, previously doesn't display borders.
Issue fork ui_patterns-3506145
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
goz commentedDigging, i think the issues comes from src/Template/TwigExtension.php
None of the 2 methods take default props values.
Comment #3
goz commentedComment #5
goz commentedComment #6
pdureau commentedThanks you for your contribution, Fabien.
SDC is not processing JSON schema's
default: https://www.drupal.org/docs/develop/theming-drupal/using-single-director...And we agree with that in UI Patterns 2: https://project.pages.drupalcode.org/ui_patterns/2-authors/0-authoring-a...
UI Patterns 2 uses
defaultwhen building the component form, as#default_value.defaultmust not be used in the rendering process (sending default value if prop value is missing or empty) because:what do you think about this?
Comment #7
goz commentedThey document it by comment, but it doesn't make it good.
For my point of view, JSON schema of a component describe how the component is build and rules applying to it.
We should rely on it, and not report some stuff in twig for something like default values, especially when the implementation is not that hard.
If i make a documentation based on component definitions, UX will be very bad to say for each default value (be careful, this default value is not a default value for the component but only for form component). Form configuration is one of the way to use components. All the ways to implement components should follow the same rules.
I understand you are aligned with how SDC work, so it's more an issue with this core module at first.
I guess waiting fir this, theme maintainers will have to keep this in mind and report themselves the default logic into their twig files. One little missing piece of code, need to be care by many sub-projects.
Comment #8
goz commentedComment #9
pdureau commented2 things to take into account: