diff --git a/CHANGES.md b/CHANGES.md index 8b0f9b1ff1..ec42849938 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -53,6 +53,7 @@ - Fix the context menu always closes after any action [Taiga #11624](https://tree.taiga.io/project/penpot/issue/11624) - Fix font selector highlight inconsistency when using keyboard navigation [Taiga #11668](https://tree.taiga.io/project/penpot/issue/11668) - Fix X & Y position do not sincronize with tokens [Taiga #11617](https://tree.taiga.io/project/penpot/issue/11617) +- Fix tooltip position after first time [Taiga #11688](https://tree.taiga.io/project/penpot/issue/11688) ## 2.8.1 (Unreleased) diff --git a/frontend/src/app/main/ui/ds/tooltip/tooltip.cljs b/frontend/src/app/main/ui/ds/tooltip/tooltip.cljs index 59a96f8c4e..39995ab816 100644 --- a/frontend/src/app/main/ui/ds/tooltip/tooltip.cljs +++ b/frontend/src/app/main/ui/ds/tooltip/tooltip.cljs @@ -154,12 +154,17 @@ the dom with the result." [tooltip placement origin-brect offset] (show-popover tooltip) - (let [tooltip-brect (dom/get-bounding-rect tooltip) + (let [saved-height (dom/get-data tooltip "height") + saved-width (dom/get-data tooltip "width") + tooltip-brect (dom/get-bounding-rect tooltip) + tooltip-brect (assoc tooltip-brect :height (or saved-height (:height tooltip-brect)) :width (or saved-width (:width tooltip-brect))) window-size (dom/get-window-size)] (when-let [[placement placement-rect] (find-matching-placement placement tooltip-brect origin-brect window-size offset)] (let [height (if (or (= placement "right") (= placement "left")) (- (:height placement-rect) arrow-height) (:height placement-rect))] + (dom/set-data! tooltip "height" (:height tooltip-brect)) + (dom/set-data! tooltip "width" (:width tooltip-brect)) (dom/set-css-property! tooltip "block-size" (dm/str height "px")) (dom/set-css-property! tooltip "inset-block-start" (dm/str (:top placement-rect) "px")) (dom/set-css-property! tooltip "inset-inline-start" (dm/str (:left placement-rect) "px")))