From 51f530e272877d82266044251214beb4384a4ca4 Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:55:15 +0800 Subject: [PATCH] Update tooltip.ts --- app/src/dialog/tooltip.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts index 6ac82bb6157..5c632783e19 100644 --- a/app/src/dialog/tooltip.ts +++ b/app/src/dialog/tooltip.ts @@ -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()) { @@ -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") { @@ -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 {