🐛 Fix tooltip height on safari

This commit is contained in:
Eva Marco 2025-06-16 14:39:59 +02:00 committed by Andrey Antukh
parent f7e94accc3
commit 691a67b595
3 changed files with 19 additions and 12 deletions

View file

@ -158,9 +158,14 @@
(let [tooltip-brect (dom/get-bounding-rect tooltip) (let [tooltip-brect (dom/get-bounding-rect tooltip)
window-size (dom/get-window-size)] window-size (dom/get-window-size)]
(when-let [[placement placement-rect] (find-matching-placement placement tooltip-brect origin-brect window-size offset)] (when-let [[placement placement-rect] (find-matching-placement placement tooltip-brect origin-brect window-size offset)]
(dom/set-css-property! tooltip "display" "grid")
(dom/set-css-property! tooltip "inset-block-start" (dm/str (:top placement-rect) "px")) (let [height (if (or (= placement "right") (= placement "left"))
(dom/set-css-property! tooltip "inset-inline-start" (dm/str (:left placement-rect) "px")) (- (:height placement-rect) arrow-height)
(:height placement-rect))]
(dom/set-css-property! tooltip "display" "grid")
(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")))
placement))) placement)))
(def ^:private schema:tooltip (def ^:private schema:tooltip

View file

@ -16,6 +16,7 @@ $arrow-side: 12px;
background-color: transparent; background-color: transparent;
overflow: hidden; overflow: hidden;
inline-size: fit-content; inline-size: fit-content;
block-size: fit-content;
} }
.tooltip-arrow { .tooltip-arrow {
@ -145,6 +146,7 @@ $arrow-side: 12px;
border: $b-1 solid var(--color-accent-primary-muted); border: $b-1 solid var(--color-accent-primary-muted);
padding: var(--sp-s) var(--sp-m); padding: var(--sp-s) var(--sp-m);
grid-area: content; grid-area: content;
block-size: fit-content;
} }
.tooltip-trigger { .tooltip-trigger {

View file

@ -74,7 +74,7 @@ export const Corners = {
> >
<Tooltip <Tooltip
id="popover-example10" id="popover-example10"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
placeSelf: "start start", placeSelf: "start start",
width: "fit-content", width: "fit-content",
@ -85,7 +85,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example2" id="popover-example2"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "start", alignSelf: "start",
justifySelf: "center", justifySelf: "center",
@ -106,7 +106,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example3" id="popover-example3"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "start", alignSelf: "start",
justifySelf: "end", justifySelf: "end",
@ -118,7 +118,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example4" id="popover-example4"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "center", alignSelf: "center",
justifySelf: "start", justifySelf: "start",
@ -130,7 +130,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example5" id="popover-example5"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "center", alignSelf: "center",
justifySelf: "center", justifySelf: "center",
@ -142,7 +142,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example6" id="popover-example6"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "center", alignSelf: "center",
justifySelf: "end", justifySelf: "end",
@ -154,7 +154,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example7" id="popover-example7"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "end", alignSelf: "end",
justifySelf: "start", justifySelf: "start",
@ -166,7 +166,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example8" id="popover-example8"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "end", alignSelf: "end",
justifySelf: "center", justifySelf: "center",
@ -178,7 +178,7 @@ export const Corners = {
</Tooltip> </Tooltip>
<Tooltip <Tooltip
id="popover-example9" id="popover-example9"
content="This is the tooltip content, and must be shown in two lines." content="This is the tooltip content, it's very long, and must be shown in three lines to check how it respond to different sizes."
style={{ style={{
alignSelf: "end", alignSelf: "end",
justifySelf: "end", justifySelf: "end",