Skip to content

Commit

Permalink
fix: focus new note on create (#791)
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Dec 27, 2021
1 parent 07678bb commit c9e448c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Expand Up @@ -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) {
Expand All @@ -327,18 +327,14 @@ 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 = () => {
const selectedTag = this.appState.selectedTag;
if (selectedTag && selectedTag.isSmartTag && !selectedTag.isAllTag) {
return;
}
return this.createNewNote(false);
return this.createNewNote();
};

get optionsSubtitle(): string {
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/views/editor/editor_view.ts
Expand Up @@ -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 {
Expand Down

0 comments on commit c9e448c

Please sign in to comment.