MDL-68353 form: filemanager label fix
authorShamim Rezaie <shamim@moodle.com>
Tue, 7 Apr 2020 15:09:55 +0000 (01:09 +1000)
committerShamim Rezaie <shamim@moodle.com>
Fri, 29 May 2020 04:37:01 +0000 (14:37 +1000)
lib/form/templates/element-filemanager.mustache

index 6f02ca0..f2607eb 100644 (file)
@@ -1,5 +1,26 @@
 {{< core_form/element-template }}
+    {{$label}}
+        {{^element.hiddenlabel}}
+            <p id="{{element.id}}_label" class="col-form-label d-inline" aria-hidden="true">
+                {{{label}}}
+            </p>
+        {{/element.hiddenlabel}}
+    {{/label}}
     {{$element}}
-        {{{element.html}}}
+        <fieldset class="w-100 m-0 p-0 border-0" id="{{element.id}}_fieldset">
+            <legend class="sr-only">{{label}}</legend>
+            {{{element.html}}}
+        </fieldset>
     {{/element}}
 {{/ core_form/element-template }}
+{{#js}}
+(function() {
+    var label = document.getElementById('{{element.id}}_label');
+    if (label) {
+        label.style.cursor = 'default';
+        label.addEventListener('click', function() {
+            document.querySelectorAll('#{{element.id}}_fieldset div.fp-toolbar a')[0].focus();
+        });
+    }
+})();
+{{/js}}