From ac1b713df2db5dd028df3f361814c73e56085a61 Mon Sep 17 00:00:00 2001 From: Szymon Fiedler Date: Thu, 4 Apr 2024 10:39:47 +0200 Subject: [PATCH] Always be closing Escape shouldn't toggle but always close the modal. --- ruby_event_store-browser/elm/src/Layout.elm | 5 ++++- ruby_event_store-browser/public/bootstrap.js | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ruby_event_store-browser/elm/src/Layout.elm b/ruby_event_store-browser/elm/src/Layout.elm index d4ae6c3920..543f7c8ce4 100644 --- a/ruby_event_store-browser/elm/src/Layout.elm +++ b/ruby_event_store-browser/elm/src/Layout.elm @@ -56,6 +56,9 @@ port requestSearch : (() -> msg) -> Sub msg port requestSearchClose : (() -> msg) -> Sub msg +port closeSearch : String -> Cmd msg + + port toggleBookmark : String -> Cmd msg @@ -151,7 +154,7 @@ update msg model = ( model, toggleDialog searchModalId ) RequestSearchClose -> - ( model, toggleDialog searchModalId ) + ( model, closeSearch searchModalId ) ToggleBookmarksMenu -> ( { model | internal = Model model.internal.search (not model.internal.displayBookmarksMenu) model.internal.bookmarks }, Cmd.none ) diff --git a/ruby_event_store-browser/public/bootstrap.js b/ruby_event_store-browser/public/bootstrap.js index da8b98d3ae..7669f23bea 100644 --- a/ruby_event_store-browser/public/bootstrap.js +++ b/ruby_event_store-browser/public/bootstrap.js @@ -11,6 +11,10 @@ app.ports.toggleDialog.subscribe(function (id) { dialog.open ? dialog.close() : dialog.showModal(); }); +app.ports.closeSearch.subscribe(function (id) { + document.querySelector(`#${id}`).close(); +}); + window.addEventListener("keydown", function (event) { if (event.key === "k" && (event.ctrlKey || event.metaKey)) { app.ports.requestSearch.send(null);