Skip to content

Commit

Permalink
Merge pull request #7458 from mbektasbbg/check_if_label_is_linked
Browse files Browse the repository at this point in the history
Make sure label is linked to a control when checking for element type
  • Loading branch information
Steven Silvester committed Dec 12, 2019
2 parents d34be89 + 2e9182b commit 7644983
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/apputils/src/toolbar.tsx
Expand Up @@ -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.
Expand Down

0 comments on commit 7644983

Please sign in to comment.