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

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

Issue 2871573004: [MD Bookmarks] Make dragging update selected items. (Closed)
Patch Set: rebase 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
« no previous file with comments | « no previous file | chrome/test/data/webui/md_bookmarks/dnd_manager_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_bookmarks/dnd_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/dnd_manager.js b/chrome/browser/resources/md_bookmarks/dnd_manager.js
index f1b0b7b47429cba2c5819fc5402069a4caa4ae7f..4e6d879043e2bd832cb284b38ec8f7777c94c4b7 100644
--- a/chrome/browser/resources/md_bookmarks/dnd_manager.js
+++ b/chrome/browser/resources/md_bookmarks/dnd_manager.js
@@ -371,7 +371,6 @@ cr.define('bookmarks', function() {
parentId = assert(node.parentId);
index = state.nodes[parentId].children.indexOf(node.id);
- // TODO(calamity): Handle dropping to an empty bookmark list.
if (position == DropPosition.BELOW)
index++;
}
@@ -403,14 +402,23 @@ cr.define('bookmarks', function() {
if (!dragElement)
return;
+ var store = bookmarks.Store.getInstance();
+ var dragId = dragElement.itemId;
+
// Determine the selected bookmarks.
- var state = bookmarks.Store.getInstance().data;
+ var state = store.data;
var draggedNodes = Array.from(state.selection.items);
+ // Change selection to the dragged node if the node is not part of the
+ // existing selection.
if (isBookmarkFolderNode(dragElement) ||
- draggedNodes.indexOf(dragElement.itemId) == -1) {
- // TODO(calamity): clear current selection.
- draggedNodes = [dragElement.itemId];
+ draggedNodes.indexOf(dragId) == -1) {
+ store.dispatch(bookmarks.actions.deselectItems());
+ if (!isBookmarkFolderNode(dragElement)) {
+ store.dispatch(
+ bookmarks.actions.selectItem(dragId, true, false, state));
+ }
+ draggedNodes = [dragId];
}
e.preventDefault();
« no previous file with comments | « no previous file | chrome/test/data/webui/md_bookmarks/dnd_manager_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698