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

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

Issue 2946883002: MD Bookmarks: Deselect items when they are moved to a new folder (Closed)
Patch Set: Created 3 years, 6 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/reducers.js
diff --git a/chrome/browser/resources/md_bookmarks/reducers.js b/chrome/browser/resources/md_bookmarks/reducers.js
index c4d142b35d5dc082f7e21af22dad23e61d243963..8337e5767457d7ca3e454c989b9b6cc528a07720 100644
--- a/chrome/browser/resources/md_bookmarks/reducers.js
+++ b/chrome/browser/resources/md_bookmarks/reducers.js
@@ -55,7 +55,7 @@ cr.define('bookmarks', function() {
* @param {!Set<string>} deleted
* @return SelectionState
*/
- SelectionState.deselectDeletedItems = function(selectionState, deleted) {
+ SelectionState.deselectItems = function(selectionState, deleted) {
return /** @type {SelectionState} */ Object.assign({}, selectionState, {
items: bookmarks.util.removeIdsFromSet(selectionState.items, deleted),
anchor: !selectionState.anchor || deleted.has(selectionState.anchor) ?
@@ -90,8 +90,16 @@ cr.define('bookmarks', function() {
case 'select-items':
return SelectionState.selectItems(selection, action);
case 'remove-bookmark':
- return SelectionState.deselectDeletedItems(
- selection, action.descendants);
+ return SelectionState.deselectItems(selection, action.descendants);
+ case 'move-bookmark':
+ // Deselect items when they are moved to another folder, since they will
+ // no longer be visible on screen (for simplicity, ignores items visible
+ // in search results).
+ if (action.parentId != action.oldParentId &&
+ selection.items.has(action.id)) {
+ return SelectionState.deselectItems(selection, new Set([action.id]));
+ }
+ return selection;
case 'update-anchor':
return SelectionState.updateAnchor(selection, action);
default:

Powered by Google App Engine
This is Rietveld 408576698