diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 7f9236fd40..0437a2a8a9 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1175,35 +1175,6 @@ function template_preprocess_item_list(&$variables) { } } -/** - * Prepares variables for inclusion in a splitbutton item list. - * - * @param array $variables - * An associative array containing: - * - items: An array of items to be displayed in the list. - * - list_type: The type of list to return (e.g. "ul", "ol"). - * - wrapper_attributes: HTML attributes to be applied to the list wrapper. - */ -function template_preprocess_splitbutton_item_list(array &$variables) { - $variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']); - foreach ($variables['items'] as &$item) { - $attributes = []; - // If the item value is an array, then it is a render array. - if (is_array($item)) { - // List items support attributes via the '#wrapper_attributes' property. - if (isset($item['#wrapper_attributes'])) { - $attributes = $item['#wrapper_attributes']; - } - } - - // Set the item's value and attributes for the template. - $item = [ - 'value' => $item, - 'attributes' => new Attribute($attributes), - ]; - } -} - /** * Prepares variables for splitbutton templates. * @@ -2102,14 +2073,6 @@ function drupal_common_theme() { 'item_list' => [ 'variables' => ['items' => [], 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => [], 'attributes' => [], 'empty' => NULL, 'context' => []], ], - 'splitbutton_item_list' => [ - 'variables' => [ - 'items' => [], - 'list_type' => 'ul', - 'wrapper_attributes' => [], - 'attributes' => [], - ], - ], 'splitbutton' => [ 'variables' => [ 'splitbutton_multiple' => TRUE, diff --git a/core/lib/Drupal/Core/Render/Element/Splitbutton.php b/core/lib/Drupal/Core/Render/Element/Splitbutton.php index 226344187a..d402289d00 100644 --- a/core/lib/Drupal/Core/Render/Element/Splitbutton.php +++ b/core/lib/Drupal/Core/Render/Element/Splitbutton.php @@ -178,9 +178,10 @@ public static function buildItemList(array &$element, array $items) { $item['#wrapper_attributes']['role'] = 'none'; } + $element['#splitbutton_item_list'] = [ '#items' => $items, - '#theme' => 'splitbutton_item_list', + '#theme' => 'item_list__splitbutton', '#attributes' => [ 'data-drupal-splitbutton-target' => $trigger_id, 'role' => 'menu', diff --git a/core/misc/splitbutton/splitbutton.css b/core/misc/splitbutton/splitbutton.css index f12706d860..5b8070d14f 100644 --- a/core/misc/splitbutton/splitbutton.css +++ b/core/misc/splitbutton/splitbutton.css @@ -4,6 +4,7 @@ } .js [data-drupal-splitbutton-item-list] { display: none; + list-style: none; } [data-drupal-splitbutton-open] [data-drupal-splitbutton-item-list] { z-index: 4; diff --git a/core/misc/splitbutton/splitbutton.es6.js b/core/misc/splitbutton/splitbutton.es6.js index 1a7aa60912..6467278b50 100644 --- a/core/misc/splitbutton/splitbutton.es6.js +++ b/core/misc/splitbutton/splitbutton.es6.js @@ -40,6 +40,14 @@ this.splitbutton.addEventListener('focusout', () => this.focusOut()); this.splitbutton.addEventListener('keydown', e => this.keydown(e)); this.trigger.addEventListener('click', e => this.clickToggle(e)); + + // The splitbutton items use the item-list template, but should not be + // styled as an item list. Removing the class here addresses this for any + // theme displaying a splitbutton. + const itemList = splitbutton.querySelector('.item-list'); + if (itemList) { + itemList.classList.remove('item-list'); + } } /** diff --git a/core/misc/splitbutton/splitbutton.js b/core/misc/splitbutton/splitbutton.js index a854337937..56d651c2f0 100644 --- a/core/misc/splitbutton/splitbutton.js +++ b/core/misc/splitbutton/splitbutton.js @@ -57,6 +57,11 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d this.trigger.addEventListener('click', function (e) { return _this.clickToggle(e); }); + var itemList = splitbutton.querySelector('.item-list'); + + if (itemList) { + itemList.classList.remove('item-list'); + } } _createClass(_class, [{ diff --git a/core/modules/system/templates/splitbutton-item-list.html.twig b/core/modules/system/templates/splitbutton-item-list.html.twig deleted file mode 100644 index 40483e1359..0000000000 --- a/core/modules/system/templates/splitbutton-item-list.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{# -/** - * @file - * Default theme implementation for a splitbutton item list. - * - * Available variables: - * - items: A list of items. Each item contains: - * - attributes: HTML attributes to be applied to each list item. - * - value: The content of the list element. - * - list_type: The tag for list element ("ul" or "ol"). - * - attributes: HTML attributes to be applied to the list. - * - * @see template_preprocess_splitbutton_item_list() - * - * @ingroup themeable - */ -#} -{% if items %} - <{{ list_type }}{{ attributes }}> - {%- for item in items -%} - {{ item.value }} - {%- endfor -%} - -{%- endif %} diff --git a/core/modules/system/tests/modules/splitbutton_test/src/Element/SplitTextField.php b/core/modules/system/tests/modules/splitbutton_test/src/Element/SplitTextField.php index 7865d60efd..ece6f9e153 100644 --- a/core/modules/system/tests/modules/splitbutton_test/src/Element/SplitTextField.php +++ b/core/modules/system/tests/modules/splitbutton_test/src/Element/SplitTextField.php @@ -87,7 +87,7 @@ public static function buildItemList(&$element, $items) { $element['#splitbutton_item_list'] = [ '#items' => $items, - '#theme' => 'splitbutton_item_list', + '#theme' => 'item_list', '#attributes' => [ 'data-drupal-splitbutton-target' => $trigger_id, 'data-drupal-item-tags' => 'li', diff --git a/core/themes/bartik/templates/splitbutton-item-list.html.twig b/core/profiles/demo_umami/themes/umami/templates/components/form/item-list--splitbutton.html.twig similarity index 84% rename from core/themes/bartik/templates/splitbutton-item-list.html.twig rename to core/profiles/demo_umami/themes/umami/templates/components/form/item-list--splitbutton.html.twig index 83d21f9f8a..235e88d8b7 100644 --- a/core/themes/bartik/templates/splitbutton-item-list.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/components/form/item-list--splitbutton.html.twig @@ -1,7 +1,7 @@ {# /** * @file - * Theme override for a splitbutton item list. + * Theme override for an item list used by splitbuttons. * * Available variables: * - items: A list of items. Each item contains: @@ -9,8 +9,6 @@ * - value: The content of the list element. * - list_type: The tag for list element ("ul" or "ol"). * - attributes: HTML attributes to be applied to the list. - * - * @see template_preprocess_splitbutton_item_list() */ #} {% if items %} diff --git a/core/themes/seven/templates/splitbutton-item-list.html.twig b/core/themes/bartik/templates/item-list--splitbutton.html.twig similarity index 84% rename from core/themes/seven/templates/splitbutton-item-list.html.twig rename to core/themes/bartik/templates/item-list--splitbutton.html.twig index 83d21f9f8a..235e88d8b7 100644 --- a/core/themes/seven/templates/splitbutton-item-list.html.twig +++ b/core/themes/bartik/templates/item-list--splitbutton.html.twig @@ -1,7 +1,7 @@ {# /** * @file - * Theme override for a splitbutton item list. + * Theme override for an item list used by splitbuttons. * * Available variables: * - items: A list of items. Each item contains: @@ -9,8 +9,6 @@ * - value: The content of the list element. * - list_type: The tag for list element ("ul" or "ol"). * - attributes: HTML attributes to be applied to the list. - * - * @see template_preprocess_splitbutton_item_list() */ #} {% if items %} diff --git a/core/profiles/demo_umami/themes/umami/templates/components/form/splitbutton-item-list.html.twig b/core/themes/claro/templates/form/item-list--splitbutton.html.twig similarity index 84% rename from core/profiles/demo_umami/themes/umami/templates/components/form/splitbutton-item-list.html.twig rename to core/themes/claro/templates/form/item-list--splitbutton.html.twig index 83d21f9f8a..235e88d8b7 100644 --- a/core/profiles/demo_umami/themes/umami/templates/components/form/splitbutton-item-list.html.twig +++ b/core/themes/claro/templates/form/item-list--splitbutton.html.twig @@ -1,7 +1,7 @@ {# /** * @file - * Theme override for a splitbutton item list. + * Theme override for an item list used by splitbuttons. * * Available variables: * - items: A list of items. Each item contains: @@ -9,8 +9,6 @@ * - value: The content of the list element. * - list_type: The tag for list element ("ul" or "ol"). * - attributes: HTML attributes to be applied to the list. - * - * @see template_preprocess_splitbutton_item_list() */ #} {% if items %} diff --git a/core/themes/claro/templates/form/splitbutton-item-list.html.twig b/core/themes/seven/templates/item-list--splitbutton.html.twig similarity index 84% rename from core/themes/claro/templates/form/splitbutton-item-list.html.twig rename to core/themes/seven/templates/item-list--splitbutton.html.twig index 83d21f9f8a..235e88d8b7 100644 --- a/core/themes/claro/templates/form/splitbutton-item-list.html.twig +++ b/core/themes/seven/templates/item-list--splitbutton.html.twig @@ -1,7 +1,7 @@ {# /** * @file - * Theme override for a splitbutton item list. + * Theme override for an item list used by splitbuttons. * * Available variables: * - items: A list of items. Each item contains: @@ -9,8 +9,6 @@ * - value: The content of the list element. * - list_type: The tag for list element ("ul" or "ol"). * - attributes: HTML attributes to be applied to the list. - * - * @see template_preprocess_splitbutton_item_list() */ #} {% if items %} diff --git a/core/themes/stable/templates/misc/splitbutton-item-list.html.twig b/core/themes/stable/templates/misc/splitbutton-item-list.html.twig deleted file mode 100644 index 3f66836428..0000000000 --- a/core/themes/stable/templates/misc/splitbutton-item-list.html.twig +++ /dev/null @@ -1,22 +0,0 @@ -{# -/** - * @file - * Theme override for a splitbutton item list. - * - * Available variables: - * - items: A list of items. Each item contains: - * - attributes: HTML attributes to be applied to each list item. - * - value: The content of the list element. - * - list_type: The tag for list element ("ul" or "ol"). - * - attributes: HTML attributes to be applied to the list. - * - * @see template_preprocess_splitbutton_item_list() - */ -#} -{% if items %} - <{{ list_type }}{{ attributes }}> - {%- for item in items -%} - {{ item.value }} - {%- endfor -%} - -{%- endif %} diff --git a/core/themes/stable9/templates/misc/splitbutton-item-list.html.twig b/core/themes/stable9/templates/misc/splitbutton-item-list.html.twig deleted file mode 100644 index 3f66836428..0000000000 --- a/core/themes/stable9/templates/misc/splitbutton-item-list.html.twig +++ /dev/null @@ -1,22 +0,0 @@ -{# -/** - * @file - * Theme override for a splitbutton item list. - * - * Available variables: - * - items: A list of items. Each item contains: - * - attributes: HTML attributes to be applied to each list item. - * - value: The content of the list element. - * - list_type: The tag for list element ("ul" or "ol"). - * - attributes: HTML attributes to be applied to the list. - * - * @see template_preprocess_splitbutton_item_list() - */ -#} -{% if items %} - <{{ list_type }}{{ attributes }}> - {%- for item in items -%} - {{ item.value }} - {%- endfor -%} - -{%- endif %}