MDL-70580 core: retrieve closest tree node in click handler.
authorPaul Holden <paulh@moodle.com>
Tue, 12 Jan 2021 20:11:25 +0000 (20:11 +0000)
committerPaul Holden <paulh@moodle.com>
Tue, 12 Jan 2021 20:17:32 +0000 (20:17 +0000)
lib/amd/build/tree.min.js
lib/amd/build/tree.min.js.map
lib/amd/src/tree.js

index ea1b92d..1d9c1c8 100644 (file)
Binary files a/lib/amd/build/tree.min.js and b/lib/amd/build/tree.min.js differ
index a78d746..46c0374 100644 (file)
Binary files a/lib/amd/build/tree.min.js.map and b/lib/amd/build/tree.min.js.map differ
index 1a97cac..167e7bb 100644 (file)
@@ -491,9 +491,9 @@ define(['jquery'], function($) {
             return;
         }
 
-        var item = $(e.target);
-
-        if (e.target !== e.currentTarget) {
+        // Get the closest tree item from the event target.
+        var item = $(e.target).closest('[role="treeitem"]');
+        if (!item.is(e.currentTarget)) {
             return;
         }