Skip to content

Commit fb47db4

Browse files
authored
prevent problematic tooltip align (#451)
* if align=="top", but there is not enough space, switch to align="bottom" * v2.13.3
1 parent abfc11d commit fb47db4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/netdata-ui",
3-
"version": "2.13.2",
3+
"version": "2.13.3",
44
"description": "netdata UI kit",
55
"main": "./lib/index.js",
66
"files": [

src/components/drops/drop/useMakeUpdatePosition.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ const getAbsoluteYPosition = (align, targetRect, dropRect) => {
3232
if (align.top === "top") return targetRect.top
3333
if (align.top === "bottom") return targetRect.bottom
3434
if (align.bottom === "bottom") return targetRect.bottom - dropRect.height
35-
if (align.bottom === "top") return targetRect.top - dropRect.height
35+
if (align.bottom === "top") {
36+
const y = targetRect.top - dropRect.height
37+
if (y < 0 && targetRect.bottom + dropRect.height < window.innerHeight) {
38+
return targetRect.bottom
39+
}
40+
return y
41+
}
3642

3743
return targetRect.top + targetRect.height / 2 - dropRect.height / 2
3844
}

0 commit comments

Comments
 (0)