*/
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;
}
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.
// 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);
}
}
}
if (next) {
next.focus();
- e.preventDefault();
+ markEventHandled(e);
}
}
},