Sfoglia il codice sorgente

Merge pull request #7458 from mbektasbbg/check_if_label_is_linked

Make sure label is linked to a control when checking for element type
Steven Silvester 5 anni fa
parent
commit
7644983844
1 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 6 2
      packages/apputils/src/toolbar.tsx

+ 6 - 2
packages/apputils/src/toolbar.tsx

@@ -327,9 +327,13 @@ export class Toolbar<T extends Widget = Widget> extends Widget {
    * Handle a DOM click event.
    */
   protected handleClick(event: Event) {
-    // Clicking a label focuses the corresponding control, so let it be.
+    // Clicking a label focuses the corresponding control
+    // that is linked with `for` attribute, so let it be.
     if (event.target instanceof HTMLLabelElement) {
-      return;
+      const forId = event.target.getAttribute('for');
+      if (forId && this.node.querySelector(`#${forId}`)) {
+        return;
+      }
     }
 
     // If this click already focused a control, let it be.