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

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

Issue 2977523002: MD Bookmarks: Scroll and select items that are added to the main list (Closed)
Patch Set: Add debouncer, rebase past DND change Created 3 years, 5 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/dnd_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/dnd_manager.js b/chrome/browser/resources/md_bookmarks/dnd_manager.js
index cbe61a67b9ff56bffde54f49609a41729a953586..bb2637e3bd8665d01dd073fa6e4c4825c724e491 100644
--- a/chrome/browser/resources/md_bookmarks/dnd_manager.js
+++ b/chrome/browser/resources/md_bookmarks/dnd_manager.js
@@ -464,11 +464,24 @@ cr.define('bookmarks', function() {
// Complete the drag by moving all dragged items to the drop
// destination.
var dropInfo = this.calculateDropInfo_(this.dropDestination_);
- this.dragInfo_.dragData.elements.forEach((item) => {
- chrome.bookmarks.move(item.id, {
- parentId: dropInfo.parentId,
- index: dropInfo.index == -1 ? undefined : dropInfo.index
- });
+ var shouldHighlight = this.shouldHighlight_(this.dropDestination_);
+ var dragElements = this.dragInfo_.dragData.elements;
+ var completedMoves = 0;
+
+ if (shouldHighlight)
+ bookmarks.ApiListener.trackUpdatedItems();
+
+ dragElements.forEach((item) => {
+ chrome.bookmarks.move(
+ item.id, {
+ parentId: dropInfo.parentId,
+ index: dropInfo.index == -1 ? undefined : dropInfo.index
+ },
+ function() {
+ completedMoves += 1;
+ if (shouldHighlight && completedMoves == dragElements.length)
+ bookmarks.ApiListener.highlightUpdatedItems();
calamity 2017/07/26 05:36:06 optional: Consider using an array of PromiseResolv
tsergeant 2017/07/26 06:34:07 Done, it works out a little bit nicer.
+ });
});
}
@@ -521,10 +534,16 @@ cr.define('bookmarks', function() {
e.preventDefault();
var dropInfo = this.calculateDropInfo_(this.dropDestination_);
- if (dropInfo.index != -1)
- chrome.bookmarkManagerPrivate.drop(dropInfo.parentId, dropInfo.index);
- else
- chrome.bookmarkManagerPrivate.drop(dropInfo.parentId);
+ var index = dropInfo.index != -1 ? dropInfo.index : undefined;
+ var shouldHighlight = this.shouldHighlight_(this.dropDestination_);
+
+ if (shouldHighlight)
+ bookmarks.ApiListener.trackUpdatedItems();
+
+ chrome.bookmarkManagerPrivate.drop(
+ dropInfo.parentId, index,
+ shouldHighlight ? bookmarks.ApiListener.highlightUpdatedItems :
+ undefined);
}
this.clearDragData_();
@@ -862,6 +881,15 @@ cr.define('bookmarks', function() {
return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId);
},
+ /**
+ * @param {DropDestination} dropDestination
+ * @private
+ */
+ shouldHighlight_: function(dropDestination) {
+ return isBookmarkItem(dropDestination.element) ||
+ isBookmarkList(dropDestination.element);
+ },
+
/** @param {bookmarks.TimerProxy} timerProxy */
setTimerProxyForTesting: function(timerProxy) {
this.timerProxy_ = timerProxy;

Powered by Google App Engine
This is Rietveld 408576698