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

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: Reformat json schema 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..34b1a953be68000e5ad6531e2855ecfcc97b49f1 100644
--- a/chrome/browser/resources/md_bookmarks/dnd_manager.js
+++ b/chrome/browser/resources/md_bookmarks/dnd_manager.js
@@ -464,12 +464,22 @@ 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 movePromises = this.dragInfo_.dragData.elements.map((item) => {
+ return new Promise((resolve) => {
+ chrome.bookmarks.move(item.id, {
+ parentId: dropInfo.parentId,
+ index: dropInfo.index == -1 ? undefined : dropInfo.index
+ }, resolve);
});
});
+
+ if (shouldHighlight) {
+ bookmarks.ApiListener.trackUpdatedItems();
+ Promise.all(movePromises)
+ .then(() => bookmarks.ApiListener.highlightUpdatedItems());
+ }
}
this.clearDragData_();
@@ -521,10 +531,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 +878,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;
« no previous file with comments | « chrome/browser/resources/md_bookmarks/dialog_focus_manager.js ('k') | chrome/browser/resources/md_bookmarks/edit_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698