- Issue created by @Grimreaper
- Merge request !270Issue #3488582 by grimreaper, pdureau: Side effect in links prop type normalization casting → (Merged) created by Grimreaper
- 🇫🇷France Grimreaper France 🇫🇷
I made a small change that fix my use case.
At least it can be used to open discussion.
- 🇫🇷France pdureau Paris
We don't allow render arrays in prop values, so in links item titles.
Instead of skipping the cast to string, we may render the renderable instead.
Let's discuss
- 🇫🇷France Grimreaper France 🇫🇷
Just made a quick call with @pdureau,
Let's add a normalize in StringPropType to handle those cases then call this normalize in LinksPropType.
Also use the occasion to potentially get rid of the normalizeAttributes method in LinksPropType to use directly the normalize of AttributesPropType.
- 🇫🇷France pdureau Paris
I see there were already a call to
AttributesPropType::normalize()
inLinksPropType::normalize()
, but you removed some apparently useless logic executed before. I hope it was not done like that in purpose.There are 3 phpunit failures in your MR:
- 1) Drupal\Tests\ui_patterns_field_formatters\Functional\FieldFormatterRenderTest::testRender
- Test 'field_formatter_default_2' failed for prop/slot 'props' of component ui_patterns_test:test-component. Selector .ui-patterns-props-string.
- 2) Drupal\Tests\ui_patterns_field_formatters\Functional\LayoutBuilderFieldFormatterRenderTest::testRender
- Test 'field_formatter_default_2' failed for prop/slot 'props' of component ui_patterns_test:test-component. Selector .ui-patterns-props-string.
- 3) Drupal\Tests\ui_patterns_field_formatters\Functional\LayoutFieldFormatterRenderTest::testRender
- Test 'field_formatter_default_2' failed for prop/slot 'props' of component ui_patterns_test:test-component. Selector .ui-patterns-props-string.
Is it related to your change?
Also, maybe we can also move some string related logic (like
::normalizeObject()
) fromAttributesPropType::normalize()
toStringPropType::normalize()
- 🇫🇷France Grimreaper France 🇫🇷
but you removed some apparently useless logic executed before. I hope it was not done like that in purpose.
Yes, I think it is a duplicated logic part and the change will give an equivalent result.
The failures are due to the normalize in StringPropType.
- 🇫🇷France Grimreaper France 🇫🇷
The problem is that it is a render array that is passed and if rendered then later on, the
are escaped. That's why the tests are failing.
I currently don't know if I should adapt the normalize or it highlights an existing problem.
- 🇫🇷France Grimreaper France 🇫🇷
I prefer to discuss it live when you will be back.
- 🇫🇷France Grimreaper France 🇫🇷
Other side effect of normalizing link title into a string with ui_icons_menu.
-
pdureau →
committed 1906eb4c on 2.0.x authored by
grimreaper →
Issue #3488582 by grimreaper, pdureau: Side effect in links prop type...
-
pdureau →
committed 1906eb4c on 2.0.x authored by
grimreaper →