Skip to content

Commit

Permalink
#216: SC_Modal: Fix pressing 'Enter' in a modal causes newlines to be…
Browse files Browse the repository at this point in the history
… inserted into a note.
  • Loading branch information
Taitava committed May 20, 2022
1 parent 8edb244 commit b749243
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/SC_Modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ export abstract class SC_Modal extends Modal {

// Approve the modal by pressing the enter key (if enabled).
if (this.plugin.settings.approve_modals_by_pressing_enter_key) {
this.scope.register([], "enter", () => {
this.scope.register([], "enter", (event: KeyboardEvent) => {
// Check that no textarea is focused and no autocomplete menu is open.
if (
0 === document.querySelectorAll("textarea:focus").length &&
0 === document.querySelectorAll("div.SC-autocomplete").length
) {
// No textareas with focus and no open autocomplete menus were found.
this.approve();
event.preventDefault();
event.stopPropagation();
}
});
}
Expand Down

0 comments on commit b749243

Please sign in to comment.