Desktop: Fixes #1142: Disallow dropping notes on sidebar Notebook header

pull/1175/head
Laurent Cozic 2019-01-31 08:02:12 +00:00
parent efcf5ecef4
commit f46e4e0cec
1 changed files with 6 additions and 0 deletions

View File

@ -40,9 +40,15 @@ class SideBarComponent extends React.Component {
const dt = event.dataTransfer; const dt = event.dataTransfer;
if (!dt) return; if (!dt) return;
// folderId can be NULL when dropping on the sidebar Notebook header. In that case, it's used
// to put the dropped folder at the root. But for notes, folderId needs to always be defined
// since there's no such thing as a root note.
if (dt.types.indexOf("text/x-jop-note-ids") >= 0) { if (dt.types.indexOf("text/x-jop-note-ids") >= 0) {
event.preventDefault(); event.preventDefault();
if (!folderId) return;
const noteIds = JSON.parse(dt.getData("text/x-jop-note-ids")); const noteIds = JSON.parse(dt.getData("text/x-jop-note-ids"));
for (let i = 0; i < noteIds.length; i++) { for (let i = 0; i < noteIds.length; i++) {
await Note.moveToFolder(noteIds[i], folderId); await Note.moveToFolder(noteIds[i], folderId);