MDL-51983 actionmenu: stop event propagation
authorRyan Wyllie <ryan@moodle.com>
Tue, 3 Nov 2015 05:29:55 +0000 (05:29 +0000)
committerRyan Wyllie <ryan@moodle.com>
Wed, 4 Nov 2015 03:41:34 +0000 (03:41 +0000)
Stop event propagation on keyboard events that have been
successfully handled by the action menu code.

lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-debug.js
lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-min.js
lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js
lib/yui/src/actionmenu/js/actionmenu.js

index 3102cd2..233dc4d 100644 (file)
Binary files a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-debug.js and b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-debug.js differ
index 3f0038c..9a92d89 100644 (file)
Binary files a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-min.js and b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu-min.js differ
index df75a4c..9925202 100644 (file)
Binary files a/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js and b/lib/yui/build/moodle-core-actionmenu/moodle-core-actionmenu.js differ
index f291a9a..0b65ef7 100644 (file)
@@ -315,18 +315,22 @@ ACTIONMENU.prototype = {
      */
     handleKeyboardEvent: function(e) {
         var next;
+        var markEventHandled = function(e) {
+            e.preventDefault();
+            e.stopPropagation();
+        };
 
         // Handle when the menu is still selected.
         if (e.currentTarget.ancestor(SELECTOR.TOGGLE, true)) {
             if ((e.keyCode === 40 || (e.keyCode === 9 && !e.shiftKey)) && this.firstMenuChild) {
                 this.firstMenuChild.focus();
-                e.preventDefault();
+                markEventHandled(e);
             } else if (e.keyCode === 38 && this.lastMenuChild) {
                 this.lastMenuChild.focus();
-                e.preventDefault();
+                markEventHandled(e);
             } else if (e.keyCode === 9 && e.shiftKey) {
                 this.hideMenu(e);
-                e.preventDefault();
+                markEventHandled(e);
             }
             return this;
         }
@@ -334,11 +338,11 @@ ACTIONMENU.prototype = {
         if (e.keyCode === 27) {
             // The escape key was pressed so close the menu.
             this.hideMenu(e);
-            e.preventDefault();
+            markEventHandled(e);
 
         } else if (e.keyCode === 32) {
             // The space bar was pressed. Trigger a click.
-            e.preventDefault();
+            markEventHandled(e);
             e.currentTarget.simulate('click');
         } else if (e.keyCode === 9) {
             // The tab key was pressed. Tab moves forwards, Shift + Tab moves backwards through the menu options.
@@ -346,13 +350,14 @@ ACTIONMENU.prototype = {
             // focus is moved to.
             if (e.target === this.firstMenuChild && e.shiftKey) {
                 this.hideMenu(e);
-                e.preventDefault();
+                markEventHandled(e);
             } else if (e.target === this.lastMenuChild && !e.shiftKey) {
                 if (this.hideMenu(e)) {
                     // Determine the next selector and focus on it.
                     next = this.menulink.next(SELECTOR.CAN_RECEIVE_FOCUS_SELECTOR);
                     if (next) {
                         next.focus();
+                        markEventHandled(e);
                     }
                 }
             }
@@ -401,7 +406,7 @@ ACTIONMENU.prototype = {
 
             if (next) {
                 next.focus();
-                e.preventDefault();
+                markEventHandled(e);
             }
         }
     },