Details #title is being escaped / stripped incorrectly

Created on 7 September 2018, over 6 years ago
Updated 25 May 2023, over 1 year ago

Problem:

When upgrading from 8.5.7 to 8.6.0 tab details are stripping HTML. Example:

$element['style'] = [
      '#type' => 'horizontal_tabs',
      '#theme_wrappers' => ['horizontal_tabs'],
      '#title' => $this->t('Style'),
      '#tree' => TRUE,
    ];

$element['layout']['lg'] = array(
      '#type' => 'details',
      '#title' => '<i class="fa fa-2x fa-desktop" aria-hidden="true"></i><span class="tab-label">' . $this->t('Large devices') . '</span>',
      '#group' => 'layout',
      '#description' => '<i class="fa fa-info-circle" aria-hidden="true"></i> <strong>' . $this->t('Help') . ':</strong> ' . $this->t('Set width and indentation for large devices.'),
    );

so that the title is completely empty:

8.5.7:

8.6.0:

The core version is the ONLY change. I couldn't find a core change which may lead to this issue. Can someone help or confirm this problem?

🐛 Bug report
Status

Closed: duplicate

Version

3.0

Component
Theme 

Last updated about 23 hours ago

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇨New Caledonia satane

    Hi. Looked into this during Drupal South 2023 code sprint, but as previsouly commented we need more information.
    Not sure in what context this happens, so I tried to reproduce within a module on 11.0-dev (in custom block configuration and build, as well as in configuration forms), but it always worked as expected (HTML tags stick when using #markup).

  • 🇩🇪Germany Anybody Porta Westfalica

    I'll have a try again with Drupal 10.1! brb

  • Status changed to Closed: duplicate over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Thank you very much for taking a look! I just checked this in Drupal 10.0.9 (related code is equal to 11.x currently) and it still doesn't work.

    I tried the implementation from the issue summary and from #4 / #5 and in both cases the content was removed!

    With just text ("TITLE TEST") in #title the result was:

    <li class="horizontal-tab-button horizontal-tab-button-0 first selected" tabindex="-1" data-horizontaltabbutton="0">
      <a href="#edit-field-paragraph-settings-0-style-spacing--fZq0LuuXqC4">
        <strong>TITLE TEST</strong>
        <span class="summary"></span>
        <span id="active-horizontal-tab" class="visually-hidden">(aktiver Reiter)</span>
      </a>
    </li>

    With HTML in the title ("<i>TITLE TEST</i>") in #title the result was:

    <li class="horizontal-tab-button horizontal-tab-button-0 first selected" tabindex="-1" data-horizontaltabbutton="0">
      <a href="#edit-field-paragraph-settings-0-style-spacing--fZq0LuuXqC4">
        <strong></strong>
        <span class="summary"></span>
        <span id="active-horizontal-tab" class="visually-hidden">(aktiver Reiter)</span>
      </a>
    </li>

    (note the empty <strong></strong>)
    Both the same using just #title or #title with #markup within (#4 / #5)

    My suggestion is, that the HTML is not stripped in PHP, but in the JavaScript when building the tabs.

    Finally I found the important missing piece -.-

    $element['style'] = [
          '#type' => 'horizontal_tabs',
          '#theme_wrappers' => ['horizontal_tabs'],
          '#title' => $this->t('Style'),
          '#tree' => TRUE,
        ];
    

    (added this to the IS now!)

    So it's not a core issue, but a field_group module issue and already reported for various field_group types!
    So I created a meta issue to sum that up and get things fixed at field_group: 🐛 [META] Fix HTML escaping issues Active

    Closing this as duplicate, thank you all so much and sorry.

  • 🇩🇪Germany Anybody Porta Westfalica

    Moving the issue over to Field Group where it belongs.

Production build 0.71.5 2024