MDL-68353 form: filepicker label fix
authorShamim Rezaie <shamim@moodle.com>
Mon, 11 May 2020 23:49:07 +0000 (09:49 +1000)
committerShamim Rezaie <shamim@moodle.com>
Fri, 29 May 2020 04:50:32 +0000 (14:50 +1000)
lib/form/templates/element-filepicker.mustache

index 6f02ca0..579cf20 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 .fp-btn-choose')[0].focus();
+        });
+    }
+})();
+{{/js}}