Problem/Motivation

when a component contains some form elements for example, and that exact component is injected, with twig, into the slot of another components, then the html is being filtered and all form elements disappeared.

Command icon 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

just_like_good_vibes created an issue. See original summary.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Active » Needs review
just_like_good_vibes’s picture

Assigned: pdureau » just_like_good_vibes
Status: Needs review » Needs work

sorry a last error to correct

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Needs work » Needs review

olé !

smustgrave’s picture

Just want to chime in that this was found while converting component() to include(). In ui_suite_uswds we use nested include() in the page.html.twig and without this fix it's not possible. SO thanks for the quick fix!!

pdureau’s picture

Assigned: pdureau » just_like_good_vibes
Status: Needs review » Needs work

With your change, do we lose this logic?

      // Twig `is sequence` and `is mapping `tests are not useful when a list
      // of renderables has mapping keys (non consecutive, strings) instead of
      // sequence (integer, consecutive) keys. For example a list of blocks
      // from page layout or layout builder: each block is keyed by its UUID.
      // So, transform this list of renderables to a proper Twig sequence.
      return array_values($value);

I don't see the array_values equivalent in:

      $value = array_map(static fn($item) => self::normalize($item), $value);
      return (count($value) === 1) ? reset($value) : $value;
just_like_good_vibes’s picture

Hello,
array_map is always loosing keys, so yes the logic is kept.
i will add a test for that

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Needs work » Needs review

ok, back for review

just_like_good_vibes’s picture

i added another check just for you :)

pdureau’s picture

Status: Needs review » Reviewed & tested by the community

I will merge today

just_like_good_vibes’s picture

thanks Pierre

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Reviewed & tested by the community » Fixed
grimreaper’s picture

Hi,

Thanks for the additional fixes, ok for me.

grimreaper’s picture

Status: Fixed » Needs work

Hi,

I think there is still a remaining case not handled.

With UI Suite Bootstrap 5.1.x, UI Patterns 2.0.x and Drupal Commerce, on user/1/address-book, I have:

Drupal\Core\Render\Component\Exception\InvalidComponentException: [items[1].title] Object value found, but a string is required in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 203 of core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).

So I tried in app/modules/contrib/ui_patterns/src/Plugin/UiPatterns/PropType/LinksPropType.php::normalizeTitle() to add:

    elseif ($title instanceof FormattableMarkup) {
      $title = $title->render();
    }

Then another case when $title is a renderable array.

just_like_good_vibes’s picture

hello,
this belongs to another ticket, because it is linkproptype normalization and not slot

steveoriol’s picture

With UI Suite DaisyUI, UI Patterns 2.0.x
and Drupal Commerce (on user/1/address-book)
or Webform (on user/1/submissions) ...
Same error as grimreaper

just_like_good_vibes’s picture

Status: Needs work » Fixed

see #3492211: [2.0.0-beta6] Normalization...suite, we stay closed this issue and work in a new clean one.

pdureau’s picture

Title: [2.0.0-rc1] normalization of slots triggers some unwanted filtering » [2.0.0-beta6] normalization of slots triggers some unwanted filtering
pdureau’s picture

Status: Fixed » Closed (fixed)