From 9c7eac481e2a1c9b083776bbe2118ef57fa444b9 Mon Sep 17 00:00:00 2001 From: Ramon Lapenta Date: Tue, 10 Mar 2020 11:10:04 -0600 Subject: [PATCH] Add "option" to list elements that belong to "listbox" The accessibility attribute `role="listbox"` requires its immediate children to be set as `role="option"`, currently they don't have this option and accessibility tests are failing. --- src/Forms/CheckboxSetField.php | 1 + src/Forms/OptionsetField.php | 1 + templates/SilverStripe/Forms/CheckboxSetField.ss | 2 +- templates/SilverStripe/Forms/OptionsetField.ss | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Forms/CheckboxSetField.php b/src/Forms/CheckboxSetField.php index 1d8f94709..1af9f9cbe 100644 --- a/src/Forms/CheckboxSetField.php +++ b/src/Forms/CheckboxSetField.php @@ -90,6 +90,7 @@ class CheckboxSetField extends MultiSelectField $options->push(new ArrayData(array( 'ID' => $itemID, 'Class' => $extraClass, + 'Role' => 'option', 'Name' => "{$this->name}[{$itemValue}]", 'Value' => $itemValue, 'Title' => $title, diff --git a/src/Forms/OptionsetField.php b/src/Forms/OptionsetField.php index 7054b0759..934d7e1e5 100644 --- a/src/Forms/OptionsetField.php +++ b/src/Forms/OptionsetField.php @@ -72,6 +72,7 @@ class OptionsetField extends SingleSelectField return new ArrayData(array( 'ID' => $this->getOptionID($value), 'Class' => $this->getOptionClass($value, $odd), + 'Role' => 'option', 'Name' => $this->getOptionName(), 'Value' => $value, 'Title' => $title, diff --git a/templates/SilverStripe/Forms/CheckboxSetField.ss b/templates/SilverStripe/Forms/CheckboxSetField.ss index f869d596f..75d1a62b9 100644 --- a/templates/SilverStripe/Forms/CheckboxSetField.ss +++ b/templates/SilverStripe/Forms/CheckboxSetField.ss @@ -1,7 +1,7 @@