Skip to content

Commit 2e07fe1

Browse files
committed
fix: bottom property edit popup
1 parent bc9a076 commit 2e07fe1

4 files changed

Lines changed: 29 additions & 10 deletions

File tree

src/main/frontend/components/block.cljs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,8 +2616,9 @@
26162616
[^js pill]
26172617
(when-let [trigger (some-> pill
26182618
(.querySelector ".bottom-property-content .jtrigger"))]
2619-
(.click trigger)
2620-
(some-> trigger .focus)
2619+
(if (some-> pill (.querySelector ".bottom-property-content [data-popup-active]"))
2620+
(shui/popup-hide!)
2621+
(.click trigger))
26212622
true))
26222623

26232624
(defn- current-bottom-pill
@@ -2722,12 +2723,9 @@
27222723
{:type "button"
27232724
:on-click (fn [e]
27242725
(util/stop e)
2725-
(when-let [trigger
2726-
(some-> (.-currentTarget e)
2727-
(.closest ".bottom-property-content")
2728-
(.querySelector ".jtrigger"))]
2729-
(.click trigger)
2730-
(some-> trigger .focus)))}
2726+
(some-> (.-currentTarget e)
2727+
(.closest ".bottom-property-pill")
2728+
trigger-bottom-pill-edit!))}
27312729
(ui/icon "edit" {:size 15})])]]))
27322730

27332731
(defn- block-below-positioned-properties-cp

src/main/frontend/components/block.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ html.is-mac {
10661066
.bottom-properties-row:focus {
10671067
outline: none;
10681068
box-shadow: inset 0 0 0 1px var(--ls-link-text-color);
1069-
border-radius: 9999px;
1069+
border-radius: 6px;
10701070
}
10711071

10721072
.bottom-property-pill {

src/main/frontend/components/property/value.cljs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,12 @@
463463
(property-handler/remove-block-property! (:db/id block)
464464
(:db/ident property)))
465465

466+
(defn- prevent-bottom-property-edit-pointer-dismiss
467+
[^js e]
468+
(when (some-> (.-target e) (.closest ".bottom-property-edit-icon"))
469+
(.preventDefault e)
470+
false))
471+
466472
(rum/defc date-picker
467473
[value {:keys [block property datetime? on-change on-delete del-btn? editing? multiple-values? other-position?
468474
suppress-inline-edit-icon? property-position]}]
@@ -481,7 +487,9 @@
481487
(editor-handler/save-current-block!)
482488
(when-not config/publishing?
483489
(shui/popup-show! (.-target e) content-fn
484-
{:align "start" :auto-focus? true}))))
490+
{:align "start"
491+
:auto-focus? true
492+
:content-props {:onPointerDownOutside prevent-bottom-property-edit-pointer-dismiss}}))))
485493
repeated-task? (:logseq.property.repeat/repeated? block)]
486494
(if editing?
487495
(content-fn {:id :date-picker})

src/test/frontend/components/property/value_test.cljs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,16 @@
6565
:block/uuid #uuid "11111111-1111-1111-1111-111111111111"}]
6666
(is (= (:logseq.property/default-value property)
6767
(#'property-value/resolved-property-value-for-render loaded-block property false)))))
68+
69+
(deftest bottom-property-edit-pointer-dismiss-handler-test
70+
(let [edit-button (js-obj "closest" (fn [selector]
71+
(when (= selector ".bottom-property-edit-icon")
72+
#js {})))
73+
other-target (js-obj "closest" (constantly nil))
74+
prevent-default-called? (atom false)
75+
edit-event (js-obj "target" edit-button
76+
"preventDefault" #(reset! prevent-default-called? true))
77+
other-event (js-obj "target" other-target)]
78+
(is (false? (#'property-value/prevent-bottom-property-edit-pointer-dismiss edit-event)))
79+
(is (true? @prevent-default-called?))
80+
(is (nil? (#'property-value/prevent-bottom-property-edit-pointer-dismiss other-event)))))

0 commit comments

Comments
 (0)