diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts
index fb8596f10..203e015bd 100644
--- a/app/src/dialog/tooltip.ts
+++ b/app/src/dialog/tooltip.ts
@@ -30,19 +30,20 @@ export const showTooltip = (message: string, target: Element, error = false) =>
let left = targetRect.left;
let top = targetRect.bottom;
const position = target.getAttribute("data-position")
+ const parentRect = target.parentElement.getBoundingClientRect();
if (position === "right") {
// block icon
left = targetRect.right - messageElement.clientWidth;
} else if (position === "parentE") {
- // tree and outline
- const parentRect = target.parentElement.getBoundingClientRect();
+ // file tree and outlinećbacklink
top = parentRect.top;
left = parentRect.right + 8;
}
+ const topHeight = position === "parentE" ? top : targetRect.top;
const bottomHeight = window.innerHeight - top;
- messageElement.style.maxHeight = Math.max(targetRect.top, bottomHeight) + "px";
- if (targetRect.top > bottomHeight) {
- messageElement.style.top = (targetRect.top - messageElement.clientHeight) + "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 {
messageElement.style.top = top + "px";
}
diff --git a/app/src/util/Tree.ts b/app/src/util/Tree.ts
index 6655a4936..82d91d680 100644
--- a/app/src/util/Tree.ts
+++ b/app/src/util/Tree.ts
@@ -4,6 +4,7 @@ import {isMobile} from "./functions";
import {mathRender} from "../protyle/render/mathRender";
import {unicode2Emoji} from "../emoji";
import {Constants} from "../constants";
+import {escapeAriaLabel} from "./escape";
export class Tree {
public element: HTMLElement;
@@ -63,10 +64,10 @@ export class Tree {
} else if (item.type === "tag") {
iconHTML = '';
} else if (item.type === "backlink") {
- titleTip = ` aria-label="${item.hPath}"`;
+ titleTip = ` aria-label="${escapeAriaLabel(item.hPath)}"`;
iconHTML = ``;
} else if (item.type === "outline") {
- titleTip = ` aria-label="${Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name))}"`;
+ titleTip = ` aria-label="${escapeAriaLabel(Lute.BlockDOM2Content(item.name))}"`;
iconHTML = ``;
}
let countHTML = "";
@@ -148,7 +149,7 @@ data-def-path="${item.defPath}">
${iconHTML}
- ${item.content}
+ ${item.content}
${countHTML}
${this.blockExtHTML || ""}
`;