Problem/Motivation

In LinksPropType, line 106, we cast $item["text"] as string:

      if (array_key_exists("text", $item)) {
        // Examples: links.html.twig, breadcrumb.html.twig, pager.html.twig,
        // views_mini_pager.html.twig.
        $item["title"] = (string) $item["text"];
        unset($item["text"]);
      }

However, sometimes $item["text"] is an array, found in Layout Builder with UI suite Bootstrap.

So, there is a warning which is breaking Layout Builder

Proposed resolution

  1. Try to reproduce the issue
  2. Test if $item["text"] is an array before casting
  3. If it is an array, investigate why ? A render array ? How to transform it to text?
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

pdureau created an issue. See original summary.

pdureau’s picture

pdureau’s picture

Assigned: pdureau » grimreaper
Status: Active » Needs review

Hi Florent,

this issue is related to dropbutton renderables, which are a special case of "links", where each item's 'text' is a submit form element.

For example, UI Patterns 2 is doing that in the slots source selector:

[
    "#type" => "submit"
    "#name" => "labelsettings_ui_patterns_slots_label_token_add_more"
    "#value" => "Token"
    "#submit" => array:1 [
      0 => "Drupal\ui_patterns\Element\ComponentSlotForm::addSource"
]

The issue is triggered with ui_suite_bootstrap because PreprocessLinksDropbutton maps this links structure to dropdown component.

So, I am afraid just doing if (array_key_exists("text", $item) && !is_array($item["text"])) will breaks something in UI Suite Bootsrap, where I already see a broken source selector for slots in Layout Builder.

Can we check the MR together? https://git.drupalcode.org/project/ui_patterns/-/merge_requests/218

grimreaper made their first commit to this issue’s fork.

  • pdureau committed a9cd5ffd on 2.0.x
    Issue #3474641 by pdureau, grimreaper: LinksPropType: array to string...
pdureau’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Fixed
pdureau’s picture

Status: Fixed » Closed (fixed)