MDL-68167 user: Fix missing label for participants filter input fields
authorShamim Rezaie <shamim@moodle.com>
Thu, 29 Oct 2020 17:51:08 +0000 (04:51 +1100)
committerShamim Rezaie <shamim@moodle.com>
Fri, 30 Oct 2020 05:08:56 +0000 (16:08 +1100)
user/amd/build/local/participantsfilter/filter.min.js
user/amd/build/local/participantsfilter/filter.min.js.map
user/amd/src/local/participantsfilter/filter.js

index 5c2801e..039e338 100644 (file)
Binary files a/user/amd/build/local/participantsfilter/filter.min.js and b/user/amd/build/local/participantsfilter/filter.min.js differ
index a778082..3be9a52 100644 (file)
Binary files a/user/amd/build/local/participantsfilter/filter.min.js.map and b/user/amd/build/local/participantsfilter/filter.min.js.map differ
index 445dd3a..825c9db 100644 (file)
@@ -91,6 +91,18 @@ export default class {
 
         const dataSource = filterValueNode.querySelector('select');
 
+        // Set an ID for this filter value element.
+        dataSource.id = 'filter-value-' + dataSource.getAttribute('data-field-name');
+
+        // Create a hidden label for the filter value.
+        const filterValueLabel = document.createElement('label');
+        filterValueLabel.setAttribute('for', dataSource.id);
+        filterValueLabel.classList.add('sr-only');
+        filterValueLabel.innerText = dataSource.getAttribute('data-field-title');
+
+        // Append this label to the filter value container.
+        filterValueNode.appendChild(filterValueLabel);
+
         // If there are any initial values then attempt to apply them.
         initialValues.forEach(filterValue => {
             let selectedOption = dataSource.querySelector(`option[value="${filterValue}"]`);