Fix Shift-drag/Cmd-drag to tag selector to remove tags

Apparently we implemented this 5 years ago in #873 and then broke it
(with the move to React, I think) without ever announcing it as a new
feature in Zotero 5? Anyway, this restores it, using Cmd on macOS (the
same as for moving vs copying items, or files in Finder).
This commit is contained in:
Dan Stillman 2020-04-08 03:50:36 -04:00
parent 5bb2486040
commit 90b393ed79

View file

@ -538,14 +538,13 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
return;
}
// Store the event, because drop event does not have shiftKey attribute set
Zotero.DragDrop.currentEvent = event;
elem.classList.add('dragged-over');
event.preventDefault();
event.dataTransfer.dropEffect = "copy";
// Don't show + cursor when removing tags
var remove = (Zotero.isMac && event.metaKey) || (!Zotero.isMac && event.shiftKey);
event.dataTransfer.dropEffect = remove ? "move" : "copy";
},
onDragExit: function (event) {
Zotero.DragDrop.currentEvent = null;
event.target.classList.remove('dragged-over');
},
onDrop: async function(event) {
@ -564,6 +563,9 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
return;
}
// Remove tags on Cmd-drag/Shift-drag
var remove = (Zotero.isMac && event.metaKey) || (!Zotero.isMac && event.shiftKey);
return Zotero.DB.executeTransaction(function* () {
ids = ids.split(',');
var items = Zotero.Items.get(ids);
@ -571,9 +573,10 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
for (let i=0; i<items.length; i++) {
let item = items[i];
if (Zotero.DragDrop.currentEvent.shiftKey) {
if (remove) {
item.removeTag(value);
} else {
}
else {
item.addTag(value);
}
yield item.save();