From 2473a780d1fdcc3120544312030f33eba3c8ff8b Mon Sep 17 00:00:00 2001 From: Antonella Sgarlatta Date: Wed, 16 Jun 2021 14:13:03 -0300 Subject: [PATCH] fix: scroll notes list when navigating with arrow keys --- app/assets/javascripts/views/editor/editor_view.ts | 3 --- app/assets/javascripts/views/notes/notes_view.ts | 12 ++++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index 16cc59035..8cb4c3559 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -285,9 +285,6 @@ class EditorViewCtrl extends PureViewCtrl { if (note.dirty) { this.showSavingStatus(); } - if (note.safeText().length === 0 && !showProtectedWarning) { - this.focusTitle(); - } } async dismissProtectedWarning() { diff --git a/app/assets/javascripts/views/notes/notes_view.ts b/app/assets/javascripts/views/notes/notes_view.ts index c5bcb03ee..e59300f28 100644 --- a/app/assets/javascripts/views/notes/notes_view.ts +++ b/app/assets/javascripts/views/notes/notes_view.ts @@ -411,6 +411,8 @@ class NotesViewCtrl extends PureViewCtrl { await this.flushUI(); await this.reloadNotes(); await this.appState.noteTags.reloadTags(); + const noteTitleEditorElement = document.getElementById('note-title-editor'); + noteTitleEditorElement?.focus(); } async handleTagChange(tag: SNTag) { @@ -789,7 +791,10 @@ class NotesViewCtrl extends PureViewCtrl { return candidate.uuid === this.activeEditorNote?.uuid; }); if (currentIndex + 1 < displayableNotes.length) { - this.selectNote(displayableNotes[currentIndex + 1]); + const nextNote = displayableNotes[currentIndex + 1]; + this.selectNote(nextNote); + const nextNoteElement = document.getElementById(`note-${nextNote.uuid}`); + nextNoteElement?.focus(); } } @@ -806,7 +811,10 @@ class NotesViewCtrl extends PureViewCtrl { const displayableNotes = this.state.notes; const currentIndex = displayableNotes.indexOf(this.activeEditorNote!); if (currentIndex - 1 >= 0) { - this.selectNote(displayableNotes[currentIndex - 1]); + const previousNote = displayableNotes[currentIndex - 1]; + this.selectNote(previousNote); + const previousNoteElement = document.getElementById(`note-${previousNote.uuid}`); + previousNoteElement?.focus(); return true; } else { return false;