Skip to content

Commit

Permalink
[dropdown] Rename popover-ref to body-ref
Browse files Browse the repository at this point in the history
For #343
  • Loading branch information
kimo-k committed Aug 7, 2024
1 parent f9e9951 commit 093a209
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/re_com/dropdown.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@
best-y (case v-pos :low lo-y :high hi-y)]
[best-x (case direction :up hi-y :down lo-y best-y)]))

(defn body-wrapper [{:keys [state theme anchor-ref popover-ref anchor-position direction]} & children]
(let [set-popover-ref! #(reset! popover-ref %)
optimize-position! #(reset! anchor-position (optimize-position! @anchor-ref @popover-ref
(defn body-wrapper [{:keys [state theme anchor-ref body-ref anchor-position direction]} & children]
(let [set-body-ref! #(reset! body-ref %)
optimize-position! #(reset! anchor-position (optimize-position! @anchor-ref @body-ref
{:direction direction}))
mounted! #(do
(optimize-position!)
Expand All @@ -306,7 +306,7 @@
:anchor-left left
:top top
:left left
:ref set-popover-ref!})
:ref set-body-ref!})
:part ::body-wrapper}
theme)]
children)))})))
Expand All @@ -323,7 +323,7 @@
"A clickable anchor above an openable, floating body."
[& {:keys [model] :or {model (reagent/atom nil)}}]
(let [default-model model
[focused? anchor-ref popover-ref anchor-position] (repeatedly #(reagent/atom nil))
[focused? anchor-ref body-ref anchor-position] (repeatedly #(reagent/atom nil))
anchor-ref! #(reset! anchor-ref %)
transitionable (reagent/atom
(if (deref-or-value model) :in :out))]
Expand Down Expand Up @@ -380,9 +380,9 @@
(js/setTimeout (fn [] (reset! transitionable :out)) 100))))
(on-document-click [event]
(when (and @anchor-ref
@popover-ref
@body-ref
(click-outside? @anchor-ref event)
(click-outside? @popover-ref event))
(click-outside? @body-ref event))
(transition! :close)))]
(let [theme (theme/defaults
args
Expand Down Expand Up @@ -435,7 +435,7 @@
[u/part indicator part-props :default re-com.dropdown/indicator]]})]
(when (= :open (:openable state))
[body-wrapper {:anchor-ref anchor-ref
:popover-ref popover-ref
:body-ref body-ref
:anchor-position anchor-position
:direction direction
:parts parts
Expand Down

0 comments on commit 093a209

Please sign in to comment.