fix(ux): invalid action for the block selection context menus

This commit is contained in:
charlie
2024-05-21 11:26:59 +08:00
parent ee35854498
commit 685b78e2a0
3 changed files with 68 additions and 60 deletions

View File

@@ -700,14 +700,12 @@
(defn- hide-context-menu-and-clear-selection
[e]
(state/hide-custom-context-menu!)
(let [block (.closest (.-target e) ".ls-block")]
(when-not (or (gobj/get e "shiftKey")
(util/meta-key? e)
(state/get-edit-input-id)
(and block
(or (= block (.-target e))
(.contains block (.-target e)))))
(editor-handler/clear-selection!))))
(when-not (or (gobj/get e "shiftKey")
(util/meta-key? e)
(state/get-edit-input-id)
(some-> (.-target e) (.closest ".ls-block"))
(some-> (.-target e) (.closest "[data-keep-selection]")))
(editor-handler/clear-selection!)))
(rum/defc render-custom-context-menu
[links position]
@@ -837,8 +835,11 @@
(fn [content]
(shui/popup-show! e
(fn [{:keys [id]}]
[:div {:on-click #(shui/popup-hide! id)} content])
{:on-hide state/clear-selection!
[:div {:on-click #(shui/popup-hide! id)
:data-keep-selection true}
content])
{:on-before-hide state/dom-clear-selection!
:on-after-hide state/state-clear-selection!
:content-props {:class "w-[280px] ls-context-menu-content"}
:as-dropdown? true}))