Added aria-label to Search Results Pager block

This commit is contained in:
Kyle Huynh 2023-02-02 14:47:07 -05:00
parent d30c8eda8a
commit ec96982005
3 changed files with 21 additions and 2 deletions

View file

@ -4,6 +4,11 @@
* Handles Ajax submission / updating form action on url change, etc.
*/
(function ($, Drupal, drupalSettings) {
// Replace Results per page html h3 tag with strong tag
jQuery('h3:contains("Results per page")').replaceWith(function(){
return jQuery("<strong />", {html: jQuery(this).html()});
});
// Gets current parameters minus ones provided by the form.
function getParams(query_parameter, recurse_parameter) {

View file

@ -289,6 +289,9 @@ class AdvancedSearchForm extends FormBase {
// Only show on terms after the first.
self::CONJUNCTION_FORM_FIELD => $first ? NULL : [
'#type' => 'select',
'#attributes' => [
'aria-label' => $this->t("Select search condition")
],
'#options' => [
self::AND_OP => $this->t('and'),
self::OR_OP => $this->t('or'),
@ -297,11 +300,17 @@ class AdvancedSearchForm extends FormBase {
],
self::SEARCH_FORM_FIELD => [
'#type' => 'select',
'#attributes' => [
'aria-label' => $this->t("Select search field"),
],
'#options' => $options,
'#default_value' => $term_value[self::SEARCH_FORM_FIELD],
],
self::INCLUDE_FORM_FIELD => [
'#type' => 'select',
'#attributes' => [
'aria-label' => $this->t("Select search operator"),
],
'#options' => [
self::IS_OP => $this->t('is'),
self::NOT_OP => $this->t('is not'),
@ -331,6 +340,9 @@ class AdvancedSearchForm extends FormBase {
],
self::VALUE_FORM_FIELD => [
'#type' => 'textfield',
'#attributes' => [
'aria-label' => $this->t("Enter a search term")
],
'#default_value' => $term_value[self::VALUE_FORM_FIELD],
],
'actions' => [
@ -357,7 +369,8 @@ class AdvancedSearchForm extends FormBase {
'#name' => 'remove-term-' . $i,
'#term_index' => $i,
'#attributes' => [
'class' => [$block_class_prefix . '__remove', 'fa'],
'class' => [$block_class_prefix . '__remove', 'fa' ],
'aria-label' => $this->t("Remove"),
],
'#ajax' => [
'callback' => [$this, 'ajaxCallback'],

View file

@ -245,6 +245,7 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
'#title' => Markup::create($text),
'#attributes' => [
'class' => $active ? ['pager__link', 'pager__link--is-active', 'pager__display'] : ['pager__link', 'pager__display'],
'aria-label' => $this->t("Display as " . Markup::create($text))
],
'#wrapper_attributes' => [
'class' => $active ? ['pager__item', 'is-active'] : ['pager__item'],
@ -303,7 +304,7 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
'#title_display' => 'invisible',
'#options' => $options,
'#options_attributes' => $options_attributes,
'#attributes' => ['autocomplete' => 'off'],
'#attributes' => ['autocomplete' => 'off', "aria-label"=>"Sort By"],
'#wrapper_attributes' => ['class' => ['pager__sort', 'container']],
'#name' => 'order',
'#value' => $default_value,