Skip to content

Commit

Permalink
Update tooltip.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
TCOTC committed Oct 4, 2024
1 parent 652e98b commit 51f530e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/src/dialog/tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isMobile } from "../util/functions";
import {isMobile} from "../util/functions";

export const showTooltip = (message: string, target: Element, error = false) => {
if (isMobile()) {
Expand Down Expand Up @@ -40,7 +40,7 @@ export const showTooltip = (message: string, target: Element, error = false) =>
}

if (position?.endsWith("bottom")) {
top += parseInt(position.replace("right", ""));
top += parseInt(position.replace("right", "").replace("left", ""));
} else if (position?.endsWith("top")) {
top = targetRect.top - messageElement.clientHeight;
} else if (position === "parentE") {
Expand All @@ -55,8 +55,9 @@ export const showTooltip = (message: string, target: Element, error = false) =>

const topHeight = position === "parentE" ? top : targetRect.top;
const bottomHeight = window.innerHeight - top;
messageElement.style.maxHeight = Math.max(topHeight, bottomHeight) + "px";

messageElement.style.maxHeight = Math.max(topHeight, bottomHeight) + "px";

if (top + messageElement.clientHeight > window.innerHeight && topHeight > bottomHeight) {
messageElement.style.top = ((position === "parentE" ? parentRect.bottom : targetRect.top) - messageElement.clientHeight) + "px";
} else {
Expand Down

0 comments on commit 51f530e

Please sign in to comment.