1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Fixes #1816: When creating a new note, it was not possible to focus the body text field

This commit is contained in:
Laurent Cozic 2020-01-08 17:42:28 +00:00
parent b61bfd6ffe
commit 0a13c988fa
2 changed files with 13 additions and 3 deletions

View File

@ -277,8 +277,6 @@ class NoteScreenComponent extends BaseScreenComponent {
const resourceIds = await Note.linkedResourceIds(this.state.note.body); const resourceIds = await Note.linkedResourceIds(this.state.note.body);
await ResourceFetcher.instance().markForDownload(resourceIds); await ResourceFetcher.instance().markForDownload(resourceIds);
} }
this.focusUpdate();
} }
onMarkForDownload(event) { onMarkForDownload(event) {
@ -743,8 +741,19 @@ class NoteScreenComponent extends BaseScreenComponent {
this.setState({ titleTextInputHeight: height }); this.setState({ titleTextInputHeight: height });
} }
scheduleFocusUpdate() {
if (this.focusUpdateIID_) clearTimeout(this.focusUpdateIID_);
this.focusUpdateIID_ = setTimeout(() => {
this.focusUpdateIID_ = null;
this.focusUpdate();
}, 100);
}
focusUpdate() { focusUpdate() {
this.scheduleFocusUpdateIID_ = null; if (this.focusUpdateIID_) clearTimeout(this.focusUpdateIID_);
this.focusUpdateIID_ = null;
if (!this.state.note) return; if (!this.state.note) return;
let fieldToFocus = this.state.note.is_todo ? 'title' : 'body'; let fieldToFocus = this.state.note.is_todo ? 'title' : 'body';
if (this.state.mode === 'view') fieldToFocus = ''; if (this.state.mode === 'view') fieldToFocus = '';

View File

@ -210,6 +210,7 @@ shared.initState = async function(comp) {
if (!comp.props.noteId) { if (!comp.props.noteId) {
note = comp.props.itemType == 'todo' ? Note.newTodo(comp.props.folderId) : Note.new(comp.props.folderId); note = comp.props.itemType == 'todo' ? Note.newTodo(comp.props.folderId) : Note.new(comp.props.folderId);
mode = 'edit'; mode = 'edit';
comp.scheduleFocusUpdate();
} else { } else {
note = await Note.load(comp.props.noteId); note = await Note.load(comp.props.noteId);
} }