Commit 49e85eef authored by Maggie Cai's avatar Maggie Cai Committed by Commit Bot

Fix an ordering issue with dragging multiple selected bookmarks.

When dragging a multi-selection of bookmarks in the manager, the order
of the selected bookmarks became the order of the selection instead of
their original displaying order.

This CL updates the order of dragged nodes to the displaying order.

BUG=794886

Change-Id: I4ab3ead0454874eee9e7dc49522156aba27f10d4
Reviewed-on: https://chromium-review.googlesource.com/c/1349130Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613009}
parent 7078f7b0
......@@ -376,7 +376,26 @@ cr.define('bookmarks', function() {
}
const state = bookmarks.Store.getInstance().data;
const draggedNodes = dragData.elements.map((item) => item.id);
let draggedNodes = [];
if (isBookmarkItem(dragElement)) {
const displayingItems =
assert(state.nodes[state.selectedFolder].children);
for (const itemId of displayingItems) {
for (const element of dragData.elements) {
if (element.id == itemId) {
draggedNodes.push(element.id);
}
}
}
} else {
draggedNodes = dragData.elements.map((item) => item.id);
}
assert(draggedNodes.length == dragData.elements.length);
const dragNodeIndex = draggedNodes.indexOf(dragElement.itemId);
assert(dragNodeIndex != -1);
......
......@@ -178,7 +178,9 @@ Polymer({
const toHighlight = /** @type {!Array<string>} */
(e.detail.filter((item) => this.displayedIds_.indexOf(item) != -1));
assert(toHighlight.length > 0);
if (toHighlight.length <= 0)
return;
const leadId = toHighlight[0];
this.dispatch(
bookmarks.actions.selectAll(toHighlight, this.getState(), leadId));
......
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