diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index 3c5f5a26a..ddde52ae0 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -186,8 +186,8 @@ class NoteScreenComponent extends BaseScreenComponent { shared.noteComponent_change(this, 'body', text); } - async saveNoteButton_press() { - await shared.saveNoteButton_press(this); + async saveNoteButton_press(folderId = null) { + await shared.saveNoteButton_press(this, folderId); Keyboard.dismiss(); } @@ -560,7 +560,12 @@ class NoteScreenComponent extends BaseScreenComponent { enabled: true, selectedFolderId: folder ? folder.id : null, onValueChange: async (itemValue, itemIndex) => { - if (note.id) await Note.moveToFolder(note.id, itemValue); + if (!note.id) { + await this.saveNoteButton_press(itemValue); + } else { + await Note.moveToFolder(note.id, itemValue); + } + note.parent_id = itemValue; const folder = await Folder.load(note.parent_id); diff --git a/ReactNativeClient/lib/components/shared/note-screen-shared.js b/ReactNativeClient/lib/components/shared/note-screen-shared.js index 3dc314f33..185f17094 100644 --- a/ReactNativeClient/lib/components/shared/note-screen-shared.js +++ b/ReactNativeClient/lib/components/shared/note-screen-shared.js @@ -10,14 +10,16 @@ shared.noteExists = async function(noteId) { return !!existingNote; } -shared.saveNoteButton_press = async function(comp) { +shared.saveNoteButton_press = async function(comp, folderId = null) { let note = Object.assign({}, comp.state.note); // Note has been deleted while user was modifying it. In that case, we // just save a new note by clearing the note ID. if (note.id && !(await shared.noteExists(note.id))) delete note.id; - if (!note.parent_id) { + if (folderId) { + note.parent_id = folderId; + } else if (!note.parent_id) { let folder = await Folder.defaultFolder(); if (!folder) return; note.parent_id = folder.id;