Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4213)

Unified Diff: chrome/browser/resources/md_bookmarks/item.js

Issue 2888863002: [MD Bookmarks] Refine mouse selection (Closed)
Patch Set: address comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_bookmarks/item.js
diff --git a/chrome/browser/resources/md_bookmarks/item.js b/chrome/browser/resources/md_bookmarks/item.js
index fdb20805c2999f683f39e46ec1b5db1ce413b88d..0bc3efa9da92961265967cb14ba288dca79be01c 100644
--- a/chrome/browser/resources/md_bookmarks/item.js
+++ b/chrome/browser/resources/md_bookmarks/item.js
@@ -77,10 +77,9 @@ Polymer({
*/
onContextMenu_: function(e) {
e.preventDefault();
- if (!this.isSelectedItem_) {
- this.dispatch(bookmarks.actions.selectItem(
- this.itemId, false, false, this.getState()));
- }
+ if (!this.isSelectedItem_)
+ this.selectThisItem_();
+
this.fire('open-item-menu', {
x: e.clientX,
y: e.clientY,
@@ -94,8 +93,7 @@ Polymer({
onMenuButtonClick_: function(e) {
e.stopPropagation();
e.preventDefault();
- this.dispatch(bookmarks.actions.selectItem(
- this.itemId, false, false, this.getState()));
+ this.selectThisItem_();
this.fire('open-item-menu', {
targetElement: e.target,
});
@@ -110,6 +108,15 @@ Polymer({
},
/** @private */
+ selectThisItem_: function() {
+ this.dispatch(bookmarks.actions.selectItem(this.itemId, this.getState(), {
+ clear: true,
+ range: false,
+ toggle: false,
+ }));
+ },
+
+ /** @private */
onItemIdChanged_: function() {
// TODO(tsergeant): Add a histogram to measure whether this assertion fails
// for real users.
@@ -145,8 +152,15 @@ Polymer({
* @private
*/
onClick_: function(e) {
- this.dispatch(bookmarks.actions.selectItem(
- this.itemId, e.ctrlKey, e.shiftKey, this.getState()));
+ // Ignore double clicks so that Ctrl double-clicking an item won't deselect
+ // the item before opening.
+ if (e.detail != 2) {
+ this.dispatch(bookmarks.actions.selectItem(this.itemId, this.getState(), {
+ clear: !e.ctrlKey,
+ range: e.shiftKey,
+ toggle: e.ctrlKey && !e.shiftKey,
+ }));
+ }
e.stopPropagation();
e.preventDefault();
},
« no previous file with comments | « chrome/browser/resources/md_bookmarks/dnd_manager.js ('k') | chrome/browser/resources/md_bookmarks/reducers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698