Skip to content

Commit cdbda8a

Browse files
authored
Fix roam studio and node tag popup (#421)
1 parent 3109273 commit cdbda8a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

apps/roam/src/utils/renderNodeTagPopup.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const renderNodeTagPopupButton = (
1414
) => {
1515
if (parent.dataset.attributeButtonRendered === "true") return;
1616

17+
const rect = parent.getBoundingClientRect();
1718
parent.dataset.attributeButtonRendered = "true";
1819
const wrapper = document.createElement("span");
1920
wrapper.style.position = "relative";
@@ -25,8 +26,8 @@ export const renderNodeTagPopupButton = (
2526
reactRoot.style.position = "absolute";
2627
reactRoot.style.top = "0";
2728
reactRoot.style.left = "0";
28-
reactRoot.style.width = "100%";
29-
reactRoot.style.height = "100%";
29+
reactRoot.style.width = `${rect.width}px`;
30+
reactRoot.style.height = `${rect.height}px`;
3031
reactRoot.style.pointerEvents = "none";
3132
reactRoot.style.zIndex = "10";
3233

@@ -49,8 +50,6 @@ export const renderNodeTagPopupButton = (
4950
const rawBlockText = blockUid ? getTextByBlockUid(blockUid) : "";
5051
const cleanedBlockText = rawBlockText.replace(textContent, "").trim();
5152

52-
const rect = parent.getBoundingClientRect();
53-
5453
ReactDOM.render(
5554
<Popover
5655
content={
@@ -73,8 +72,11 @@ export const renderNodeTagPopupButton = (
7372
<span
7473
style={{
7574
display: "block",
75+
top: "0",
76+
left: "0",
7677
width: `${rect.width}px`,
7778
height: `${rect.height}px`,
79+
position: "absolute",
7880
pointerEvents: "auto",
7981
}}
8082
/>
@@ -83,7 +85,7 @@ export const renderNodeTagPopupButton = (
8385
position={Position.TOP}
8486
modifiers={{
8587
offset: {
86-
offset: "0, 10",
88+
offset: `${rect.width / 2}px, 10`,
8789
},
8890
arrow: {
8991
enabled: false,

0 commit comments

Comments
 (0)