Index: chrome/browser/resources/shared/js/cr/ui/menu.js |
diff --git a/chrome/browser/resources/shared/js/cr/ui/menu.js b/chrome/browser/resources/shared/js/cr/ui/menu.js |
index 3e1e3dc31fc1e0630287a9c9fb6c03d21ed4d8a7..6d11aa0a2f3051e9d8897b65e2c42fdda678a61f 100644 |
--- a/chrome/browser/resources/shared/js/cr/ui/menu.js |
+++ b/chrome/browser/resources/shared/js/cr/ui/menu.js |
@@ -34,6 +34,7 @@ cr.define('cr.ui', function() { |
this.addEventListener('mouseout', this.handleMouseOut_); |
this.classList.add('decorated'); |
+ this.setAttribute('role', 'menu'); |
this.hidden = true; // Hide the menu by default. |
// Decorate the children as menu items. |
@@ -123,6 +124,11 @@ cr.define('cr.ui', function() { |
this.selectedIndex = index; |
}, |
+ focusSelectedItem: function() { |
+ if (this.selectedItem) |
+ this.selectedItem.focus(); |
+ }, |
+ |
/** |
* Menu length |
*/ |
@@ -180,7 +186,10 @@ cr.define('cr.ui', function() { |
case 'Enter': |
case 'U+0020': // Space |
if (item) { |
- if (cr.dispatchSimpleEvent(item, 'activate', true, true)) { |
+ var activationEvent = cr.doc.createEvent('Event'); |
+ activationEvent.initEvent('activate', true, true); |
+ activationEvent.originalEvent = e; |
+ if (item.dispatchEvent(activationEvent)) { |
if (item.command) |
item.command.execute(); |
} |
@@ -208,8 +217,10 @@ cr.define('cr.ui', function() { |
if (oldSelectedItem) |
oldSelectedItem.selected = false; |
var item = this.selectedItem; |
- if (item) |
+ if (item) { |
item.selected = true; |
+ this.focusSelectedItem(); |
+ } |
} |
/** |