Commit f65fe25c authored by Christopher Lam's avatar Christopher Lam Committed by Commit Bot

[MD Bookmarks] Fix right-click showing browser context menu.

This CL fixes an issue where the right-click of a bookmark item wouldn't show a
new command menu when a command menu was already open. This was caused by the
mousedown on the original menu not closing the menu.

When cr-action-menu changed to no longer be a type extension, the event was no
longer fired by the dropdown itself, and rather a child. This CL changes the
event expectation so that the menu will close correctly.

Bug: 825119
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I1cd5494c7208b21d55f817303389bb845794458e
Reviewed-on: https://chromium-review.googlesource.com/1013769
Commit-Queue: calamity <calamity@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551615}
parent 957a0d72
......@@ -795,7 +795,7 @@ cr.define('bookmarks', function() {
* @private
*/
onMenuMousedown_: function(e) {
if (e.path[0] != this.$.dropdown.getIfExists())
if (e.path[0].tagName != 'DIALOG')
return;
this.closeCommandMenu();
......
......@@ -583,6 +583,25 @@ suite('<bookmarks-item> CommandManager integration', function() {
chrome.bookmarkManagerPrivate.copy = bmpCopyFunction;
chrome.bookmarkManagerPrivate.cut = bmpCutFunction;
});
test('context menu disappears immediately on right click', function() {
customClick(items[0], {button: 1}, 'contextmenu');
assertDeepEquals(['11'], normalizeIterable(store.data.selection.items));
let dropdown = commandManager.$.dropdown.getIfExists();
let dialog = dropdown.getDialog();
assertTrue(dropdown.open);
let x = dialog.offsetLeft + dialog.offsetWidth + 5;
let y = dialog.offsetHeight;
// Ensure the dialog is the target even when clicking outside it, and send
// a context menu event which should immediately dismiss the dialog,
// allowing subsequent events to bubble through to elements below.
assertEquals(dropdown, commandManager.root.elementFromPoint(x, y));
assertEquals(dialog, dropdown.root.elementFromPoint(x, y));
customClick(dialog, {clientX: x, clientY: y, button: 1}, 'contextmenu');
assertFalse(dropdown.open);
});
});
suite('<bookmarks-command-manager> whole page integration', function() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment