From 8f2a5064cb66b304eb36254b89b0ddd6ae4ba271 Mon Sep 17 00:00:00 2001
From: Sebastian Holmqvist <1297882+csholmq@users.noreply.github.com>
Date: Thu, 19 Oct 2023 17:01:43 +0200
Subject: [PATCH 1/3] fix(tooltip): remove redundant scroll offset
window.scrollY is already account for which means document.body.scrollTop incorrectly offsets the tooltip vertically.
The same is not true for horizontal position.
---
packages/mermaid/src/diagrams/flowchart/flowDb.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.js b/packages/mermaid/src/diagrams/flowchart/flowDb.js
index 9a9394e543..501479239b 100644
--- a/packages/mermaid/src/diagrams/flowchart/flowDb.js
+++ b/packages/mermaid/src/diagrams/flowchart/flowDb.js
@@ -425,7 +425,7 @@ const setupToolTips = function (element) {
tooltipElem
.text(el.attr('title'))
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
- .style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
+ .style('top', window.scrollY + rect.top - 14 + 'px');
tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, '
'));
el.classed('hover', true);
})
From a3ee21d7fc16c47315d2fa071344eaa6be2f1223 Mon Sep 17 00:00:00 2001
From: Sebastian Holmqvist <1297882+csholmq@users.noreply.github.com>
Date: Fri, 20 Oct 2023 08:39:42 +0200
Subject: [PATCH 2/3] fix(tooltip): change position of tooltip to not cover
node
Position the tooltip centered, just below the node being hovered.
Update packages/mermaid/src/diagrams/flowchart/flowDb.js
Co-authored-by: Sidharth Vinod
---
packages/mermaid/src/diagrams/flowchart/flowDb.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.js b/packages/mermaid/src/diagrams/flowchart/flowDb.js
index 501479239b..f224c9bace 100644
--- a/packages/mermaid/src/diagrams/flowchart/flowDb.js
+++ b/packages/mermaid/src/diagrams/flowchart/flowDb.js
@@ -425,7 +425,7 @@ const setupToolTips = function (element) {
tooltipElem
.text(el.attr('title'))
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
- .style('top', window.scrollY + rect.top - 14 + 'px');
+ .style('top', window.scrollY + rect.bottom + 'px');
tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, '
'));
el.classed('hover', true);
})
From 4a92fc5c921e6c0df350705ee46407a090d3daea Mon Sep 17 00:00:00 2001
From: Sidharth Vinod
Date: Thu, 9 Nov 2023 14:20:06 +0530
Subject: [PATCH 3/3] Fix lint
---
packages/mermaid/src/diagrams/flowchart/flowDb.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.js b/packages/mermaid/src/diagrams/flowchart/flowDb.js
index f224c9bace..da67248f12 100644
--- a/packages/mermaid/src/diagrams/flowchart/flowDb.js
+++ b/packages/mermaid/src/diagrams/flowchart/flowDb.js
@@ -425,7 +425,7 @@ const setupToolTips = function (element) {
tooltipElem
.text(el.attr('title'))
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
- .style('top', window.scrollY + rect.bottom + 'px');
+ .style('top', window.scrollY + rect.bottom + 'px');
tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, '
'));
el.classed('hover', true);
})