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:
parent
5bb2486040
commit
90b393ed79
1 changed files with 9 additions and 6 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue