From dc6acfab9ddf51d5fa0ef79c7aeeaccdd8b4a006 Mon Sep 17 00:00:00 2001 From: DianaXWiki Date: Wed, 21 May 2025 15:47:39 +0300 Subject: [PATCH] Prevent default closing of modal #1831 --- www/kanban/inner.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/www/kanban/inner.js b/www/kanban/inner.js index c746cb74c..4cb9ab9dd 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -285,7 +285,7 @@ define([ editor.replaceSelection($(mt)[0].outerHTML); } }); - UIElements.updateToolbarVisibility(markdownEditorWrapper, markdownTb.toolbar, editor); + var toggleButtonMarkdown = UIElements.updateToolbarVisibility(markdownEditorWrapper, markdownTb.toolbar, editor); $(window).on('resize', function() { UIElements.updateToolbarVisibility(markdownEditorWrapper, markdownTb.toolbar, editor); }); @@ -295,7 +295,19 @@ define([ e.stopPropagation(); editor.focus(); // Focus the editor instead of closing the modal } - }); + else if (e.which == 13 || e.which == 9) { // "Enter" or "Tab" key should not close modal + e.stopPropagation(); + } + }); + $(toggleButtonMarkdown).on('keydown', function (e) { + if (e.which === 13) { // "Enter" should toggle the toolbar, but not close the modal + e.preventDefault(); + e.stopPropagation(); + $(this).click(); // simulate click to toggle + } else if (e.which === 9) { + e.stopPropagation(); + } + }); $(text).before(markdownTb.toolbar); editor.refresh(); var body = {