fix: focus new note on create (#791)

This commit is contained in:
Mo
2021-12-27 15:42:48 -06:00
committed by GitHub
parent 07678bbd32
commit c9e448c7b6
2 changed files with 8 additions and 6 deletions

View File

@@ -318,7 +318,7 @@ export class NotesViewState {
}
};
createNewNote = async (focusNewNote = true) => {
createNewNote = async () => {
this.appState.notes.unselectNotes();
let title = `Note ${this.notes.length + 1}`;
if (this.isFiltering) {
@@ -327,10 +327,6 @@ export class NotesViewState {
await this.appState.createEditor(title);
this.reloadNotes();
this.appState.noteTags.reloadTags();
const noteTitleEditorElement = document.getElementById('note-title-editor');
if (focusNewNote) {
noteTitleEditorElement?.focus();
}
};
createPlaceholderNote = () => {
@@ -338,7 +334,7 @@ export class NotesViewState {
if (selectedTag && selectedTag.isSmartTag && !selectedTag.isAllTag) {
return;
}
return this.createNewNote(false);
return this.createNewNote();
};
get optionsSubtitle(): string {

View File

@@ -183,6 +183,12 @@ export class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
if (this.note.dirty) {
this.showSavingStatus();
}
if (this.editor.isTemplateNote) {
this.$timeout(() => {
this.focusTitle();
});
}
}
private onNoteChanges(note: SNNote, source: PayloadSource): void {