diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index 8c6ff4f67..f4c93b328 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -277,8 +277,6 @@ class NoteScreenComponent extends BaseScreenComponent { const resourceIds = await Note.linkedResourceIds(this.state.note.body); await ResourceFetcher.instance().markForDownload(resourceIds); } - - this.focusUpdate(); } onMarkForDownload(event) { @@ -743,8 +741,19 @@ class NoteScreenComponent extends BaseScreenComponent { this.setState({ titleTextInputHeight: height }); } + scheduleFocusUpdate() { + if (this.focusUpdateIID_) clearTimeout(this.focusUpdateIID_); + + this.focusUpdateIID_ = setTimeout(() => { + this.focusUpdateIID_ = null; + this.focusUpdate(); + }, 100); + } + focusUpdate() { - this.scheduleFocusUpdateIID_ = null; + if (this.focusUpdateIID_) clearTimeout(this.focusUpdateIID_); + this.focusUpdateIID_ = null; + if (!this.state.note) return; let fieldToFocus = this.state.note.is_todo ? 'title' : 'body'; if (this.state.mode === 'view') fieldToFocus = ''; diff --git a/ReactNativeClient/lib/components/shared/note-screen-shared.js b/ReactNativeClient/lib/components/shared/note-screen-shared.js index cc50826bf..1a498bd18 100644 --- a/ReactNativeClient/lib/components/shared/note-screen-shared.js +++ b/ReactNativeClient/lib/components/shared/note-screen-shared.js @@ -210,6 +210,7 @@ shared.initState = async function(comp) { if (!comp.props.noteId) { note = comp.props.itemType == 'todo' ? Note.newTodo(comp.props.folderId) : Note.new(comp.props.folderId); mode = 'edit'; + comp.scheduleFocusUpdate(); } else { note = await Note.load(comp.props.noteId); }