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

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

Issue 2888863002: [MD Bookmarks] Refine mouse selection (Closed)
Patch Set: address comments 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 | « chrome/browser/resources/md_bookmarks/item.js ('k') | chrome/test/data/webui/md_bookmarks/actions_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/reducers.js
diff --git a/chrome/browser/resources/md_bookmarks/reducers.js b/chrome/browser/resources/md_bookmarks/reducers.js
index e5217cdd64be1745d1dac2acbac70d3e1785c658..0f28d8410509f08b9ed55763c56d86be5f8df5d1 100644
--- a/chrome/browser/resources/md_bookmarks/reducers.js
+++ b/chrome/browser/resources/md_bookmarks/reducers.js
@@ -19,11 +19,18 @@ cr.define('bookmarks', function() {
*/
SelectionState.selectItems = function(selectionState, action) {
var newItems = new Set();
- if (action.add)
+ if (!action.clear)
newItems = new Set(selectionState.items);
action.items.forEach(function(id) {
- newItems.add(id);
+ var add = true;
+ if (action.toggle)
+ add = !newItems.has(id);
+
+ if (add)
+ newItems.add(id);
+ else
+ newItems.delete(id);
});
return /** @type {SelectionState} */ (Object.assign({}, selectionState, {
@@ -51,7 +58,9 @@ cr.define('bookmarks', function() {
SelectionState.deselectDeletedItems = function(selectionState, deleted) {
return /** @type {SelectionState} */ Object.assign({}, selectionState, {
items: bookmarks.util.removeIdsFromSet(selectionState.items, deleted),
- anchor: null,
+ anchor: !selectionState.anchor || deleted.has(selectionState.anchor) ?
+ null :
+ selectionState.anchor,
});
};
« no previous file with comments | « chrome/browser/resources/md_bookmarks/item.js ('k') | chrome/test/data/webui/md_bookmarks/actions_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698