From 11069bdd4a1a36d5f85a186192bc4f7ff45f11c2 Mon Sep 17 00:00:00 2001 From: Tony Taylor Date: Wed, 31 Jan 2024 10:57:08 -0600 Subject: [PATCH] VACMS-16077: Sets Views Pager Heading Default to H2 (#16425) * Updates patch to set views pager heading to H2 * updates default header on content and orphaned paragraphs views. * VACMS-16077: updated composer.lock --------- Co-authored-by: Edmund Dunn --- composer.json | 2 +- composer.lock | 10 +- config/sync/views.view.content.yml | 2 +- .../sync/views.view.orphaned_paragraphs.yml | 2 +- ...onfigurable-pager-heading-default-h2.patch | 245 ++++++++++++++++++ 5 files changed, 257 insertions(+), 4 deletions(-) create mode 100644 patches/3333401-configurable-pager-heading-default-h2.patch diff --git a/composer.json b/composer.json index 9cd61f8ecc..a2336e67bc 100644 --- a/composer.json +++ b/composer.json @@ -392,7 +392,7 @@ "2942404 - Contentinfo landmark" : "https://www.drupal.org/files/issues/2023-06-30/2942404-messages-should-have-role-status.patch", "3047110 - Add workflow to taxonomy" : "https://www.drupal.org/files/issues/2023-04-14/3047110-45.patch", "3106205 - Length of menu_tree.url and menu_tree.route_param_key are too short (255 characters)": "https://www.drupal.org/files/issues/2024-01-02/3106205-length-menu-tree-too-short-48.patch", - "3333401 - Pager h4 cause accessibility flag on many pages": "https://www.drupal.org/files/issues/2023-11-01/3333401-64.patch", + "3333401 - Pager h4 cause accessibility flag on many pages": "patches/3333401-configurable-pager-heading-default-h2.patch", "3382759 - Add multiple workflow content moderation filter to Views.": "https://www.drupal.org/files/issues/2023-08-24/3382759-8.patch", "3241295 - CKEditor 5 isn't respecting field widgets row settings": "https://www.drupal.org/files/issues/2023-11-14/3241295-d10.1.6-114.patch", "3376267 - [upstream] Add style to anchor leads to unusable behavior": "https://www.drupal.org/files/issues/2023-08-09/fix_anchor_scheme_to_not_copy_on_enter-3376167-11.patch" diff --git a/composer.lock b/composer.lock index 20a98eacda..49abf1e8a7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1bd88357c60cc37eb2c92720b5436545", + "content-hash": "52a8fc943fb3e90574fb0f0ec2e4a5b0", "packages": [ { "name": "asm89/stack-cors", @@ -7524,6 +7524,10 @@ "name": "dawehner", "homepage": "https://www.drupal.org/user/99340" }, + { + "name": "dww", + "homepage": "https://www.drupal.org/user/46549" + }, { "name": "geek-merlin", "homepage": "https://www.drupal.org/user/229048" @@ -9331,6 +9335,10 @@ "name": "amitaibu", "homepage": "https://www.drupal.org/user/57511" }, + { + "name": "bluegeek9", + "homepage": "https://www.drupal.org/user/1286304" + }, { "name": "jhedstrom", "homepage": "https://www.drupal.org/user/208732" diff --git a/config/sync/views.view.content.yml b/config/sync/views.view.content.yml index defd826236..1670a828fb 100644 --- a/config/sync/views.view.content.yml +++ b/config/sync/views.view.content.yml @@ -523,7 +523,7 @@ display: offset: false offset_label: Offset quantity: 9 - pagination_heading_level: h4 + pagination_heading_level: '' exposed_form: type: basic options: diff --git a/config/sync/views.view.orphaned_paragraphs.yml b/config/sync/views.view.orphaned_paragraphs.yml index 30ab7af957..b04603861d 100644 --- a/config/sync/views.view.orphaned_paragraphs.yml +++ b/config/sync/views.view.orphaned_paragraphs.yml @@ -508,7 +508,7 @@ display: offset: false offset_label: Offset quantity: 9 - pagination_heading_level: h4 + pagination_heading_level: '' exposed_form: type: basic options: diff --git a/patches/3333401-configurable-pager-heading-default-h2.patch b/patches/3333401-configurable-pager-heading-default-h2.patch new file mode 100644 index 0000000000..6d59bc7f77 --- /dev/null +++ b/patches/3333401-configurable-pager-heading-default-h2.patch @@ -0,0 +1,245 @@ +diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php +index 11cbaf44901be7c0e09ba1206fa5def80a92956a..135d32644c038a9bff7f494b89e9685aed9c592f 100644 +--- a/core/modules/views/src/Plugin/views/pager/SqlBase.php ++++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php +@@ -68,6 +68,7 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt + $options['offset'] = ['default' => 0]; + $options['id'] = ['default' => 0]; + $options['total_pages'] = ['default' => '']; ++ $options['pagination_heading_level'] = ['default' => 'h2']; + $options['expose'] = [ + 'contains' => [ + 'items_per_page' => ['default' => FALSE], +diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +index 11cbaf44901be7c0e09ba1206fa5def80a92956a..135d32644c038a9bff7f494b89e9685aed9c592f 100644 +--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php ++++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +@@ -780,6 +780,38 @@ public function isDefaulted($option) { + return !$this->isDefaultDisplay() && !empty($this->default_display) && !empty($this->options['defaults'][$option]); + } + ++ /** ++ * Extracts heading elements from views configuration (@field_rewrite_elements). ++ */ ++ public function getHeadings() { ++ static $headings = NULL; ++ if (!isset($headings)) { ++ $elements = \Drupal::config('views.settings')->get('field_rewrite_elements'); ++ foreach ($elements as $key => $element) { ++ if (strlen($key) == 2 && $element[0] == 'H') { ++ $headings[$key] = $element; ++ } ++ } ++ } ++ return $headings; ++ } ++ ++ /** ++ * {@inheritdoc} ++ */ ++ public function getElements() { ++ static $elements = NULL; ++ if (!isset($elements)) { ++ // @todo Add possible html5 elements. ++ $elements = [ ++ '' => $this->t('- Use default -'), ++ ]; ++ $elements += $this->getHeadings(); ++ } ++ ++ return $elements; ++ } ++ + /** + * {@inheritdoc} + */ +@@ -1871,6 +1887,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { + $form['pager_options'] = [ + '#tree' => TRUE, + ]; ++ $form['pager_options']['pagination_heading_level'] = [ ++ '#title' => $this->t('Heading Level'), ++ '#options' => $this->getElements(), ++ '#type' => 'select', ++ '#default_value' => $plugin->getHeadingLevel(), ++ '#description' => $this->t('Choose a heading level equal to or one lower than the preceding header.'), ++ '#fieldset' => 'style_settings', ++ ]; + $plugin->buildOptionsForm($form['pager_options'], $form_state); + } + break; +diff --git a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php +index d02f67034417598829cf41ee2f144092df29bac4..1675f09ab978cb23f296d98c0ba02521fe5c6157 100644 +--- a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php ++++ b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php +@@ -72,6 +72,20 @@ public function setOffset($offset) { + $this->options['offset'] = $offset; + } + ++ /** ++ * Get the pager heading tag. ++ */ ++ public function getHeadingLevel() { ++ return $this->options['pagination_heading_level'] ?? 'h2'; ++ } ++ ++ /** ++ * Set the pager heading. ++ */ ++ public function setHeadingLevel($headingLevel) { ++ $this->options['pagination_heading_level'] = $headingLevel; ++ } ++ + /** + * Get the current page. + * +diff --git a/core/modules/views/src/Plugin/views/pager/Full.php b/core/modules/views/src/Plugin/views/pager/Full.php +index d02f67034417598829cf41ee2f144092df29bac4..1675f09ab978cb23f296d98c0ba02521fe5c6157 100644 +--- a/core/modules/views/src/Plugin/views/pager/Full.php ++++ b/core/modules/views/src/Plugin/views/pager/Full.php +@@ -86,10 +86,14 @@ public function render($input) { + 3 => $this->options['tags']['next'], + 4 => $this->options['tags']['last'], + ]; ++ $heading_options = [ ++ 'pagination_heading_level' => parent::getHeadingLevel(), ++ ]; + return [ + '#theme' => $this->themeFunctions(), + '#tags' => $tags, + '#element' => $this->options['id'], ++ '#options' => $heading_options, + '#parameters' => $input, + '#quantity' => $this->options['quantity'], + '#route_name' => !empty($this->view->live_preview) ? '' : '', +diff --git a/core/modules/views/src/Plugin/views/pager/Mini.php b/core/modules/views/src/Plugin/views/pager/Mini.php +index d02f67034417598829cf41ee2f144092df29bac4..1675f09ab978cb23f296d98c0ba02521fe5c6157 100644 +--- a/core/modules/views/src/Plugin/views/pager/Mini.php ++++ b/core/modules/views/src/Plugin/views/pager/Mini.php +@@ -93,10 +93,14 @@ public function render($input) { + 1 => $this->options['tags']['previous'], + 3 => $this->options['tags']['next'], + ]; ++ $heading_options = [ ++ 'pagination_heading_level' => parent::getHeadingLevel(), ++ ]; + return [ + '#theme' => $this->themeFunctions(), + '#tags' => $tags, + '#element' => $this->options['id'], ++ '#options' => $heading_options, + '#parameters' => $input, + '#route_name' => !empty($this->view->live_preview) ? '' : '', + ]; +diff --git a/core/themes/claro/templates/pager.html.twig b/core/themes/claro/templates/pager.html.twig +index d02f67034417598829cf41ee2f144092df29bac4..1675f09ab978cb23f296d98c0ba02521fe5c6157 100644 +--- a/core/themes/claro/templates/pager.html.twig ++++ b/core/themes/claro/templates/pager.html.twig +@@ -36,7 +36,8 @@ + #} + {% if items %} +