Skip to content
Snippets Groups Projects
Commit be5bf0b7 authored by Joshua Sedler's avatar Joshua Sedler :cartwheel_tone2: Committed by Julian Pustkuchen
Browse files

Issue #3473033 by grevil, anybody: Horizontal Tabs render broken, if child allows HTML

parent 7db38d54
No related branches found
No related tags found
3 merge requests!78Issue #3473033: Horizontal Tabs render broken, if child allows HTML,!69Issue #2872723 by Ruslan Piskarov: Rendering child fields in field group twig template,!55Issue #3450366: Add form-required to fieldset
Pipeline #278189 passed with warnings
......@@ -58,24 +58,3 @@ composer:
composer (next major):
after_script:
- composer require drupal/ds
#
# PHPSTAN overrides and configuration.
#
phpstan:
# Require phpstan to pass.
allow_failure: false
#
# CSpell overrides and configuration:
#
cspell:
# Require spellcheck to pass.
allow_failure: false
#
# PHPCS overrides and configuration.
#
phpcs:
# Require phpcs to pass.
allow_failure: false
......@@ -32,7 +32,6 @@
.find('> [data-horizontal-tabs-panes]')
.each((indexTabWrapper, tabWrapper) => {
const $this = $(tabWrapper).addClass('horizontal-tabs-panes');
// eslint-disable-next-line jquery/no-val
const focusID = $(
':hidden.horizontal-tabs-active-tab',
tabWrapper,
......@@ -51,28 +50,32 @@
);
tabList.removeClass('visually-hidden');
let summary;
let tabTitle;
/* eslint max-nested-callbacks: ['error', 4] */
// Transform each details into a tab.
$details.each((i, element) => {
const $thisDetail = $(element);
const summaryElement = $thisDetail.find('> summary');
const detailsTitle = summaryElement
const $summaryElement = $thisDetail.find('> summary');
const $detailsTitle = $summaryElement
.first()
.find('.details-title');
if (detailsTitle.length) {
summary = detailsTitle
.find('> span:last-child')
.html()
.trim();
if ($detailsTitle.length) {
tabTitle = $detailsTitle.find('> span:last-child').html();
} else {
summary =
summaryElement.clone().children().remove().end().html().trim() ||
summaryElement.find('> span:first-child').html().trim();
// Remove the required mark element from the tab title, if it
// exists (e.g. gin theme will have it twice).
tabTitle =
$summaryElement
.clone()
.find('.required-mark')
.remove()
.end()
.html() ||
$summaryElement.find('> span:first-child').html();
}
const horizontalTab = new Drupal.HorizontalTab({
title: summary,
title: tabTitle,
details: $thisDetail,
});
horizontalTab.item.addClass(`horizontal-tab-button-${i}`);
......
......@@ -350,9 +350,6 @@ class HorizontalTabsLabelsTest extends WebDriverTestBase {
'title' => 'Test',
]);
$this->drupalGet('node/' . $node->id());
// See if the field group supports HTML elements in the label:
// Note, for some reason only Tab 2 gets rendered on the page:
// We expect the HTML to be not escaped:
$session->elementContains('css', 'div.test-class-wrapper li.horizontal-tab-button.first > a > strong', '<em>Tab 2</em>');
}
......@@ -419,9 +416,6 @@ class HorizontalTabsLabelsTest extends WebDriverTestBase {
'title' => 'Test',
]);
$this->drupalGet('node/' . $node->id());
// See if the field group supports HTML elements in the label:
// Note, for some reason only Tab 2 gets rendered on the page:
// We expect the HTML to be not escaped:
$session->elementContains('css', 'div.test-class-wrapper li.horizontal-tab-button.first > a > strong', '&lt;em&gt;Tab 2&lt;/em&gt');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment