Skip to content

Commit eff2f9a

Browse files
committed
fix: info box not visible in viewport when element is at the very bottom
1 parent ae85c59 commit eff2f9a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@ function RemoteFunctions(config) {
948948

949949
if (isOverlap) {
950950
const windowWidth = window.innerWidth;
951+
const viewportHeight = window.innerHeight;
951952

952953
// Estimate the height of the info box based on its content
953954
// base height for tag name + padding
@@ -963,9 +964,21 @@ function RemoteFunctions(config) {
963964
estimatedHeight += 15;
964965
}
965966

966-
// align with the bottom of the info box
967+
// check if element is near bottom of viewport
968+
const elementBottomFromViewportTop = elemBounds.bottom;
969+
const availableSpaceBelow = viewportHeight - elementBottomFromViewportTop;
970+
971+
// align with the bottom of the info box (original behavior)
967972
topPos = (elemBounds.top + elemBounds.height - estimatedHeight) + scrollTop;
968973

974+
// If element is near bottom and there's not enough space below,
975+
// push the info box up a bit to prevent scrollbar
976+
if (availableSpaceBelow < estimatedHeight + 10) {
977+
// Push it up by the amount it would overflow
978+
const pushUpAmount = estimatedHeight - availableSpaceBelow;
979+
topPos -= pushUpAmount;
980+
}
981+
969982
// decide whether position at left or right based on available space
970983
// check if there's enough space on the left side
971984
if (elemBounds.left > boxWidth + 10) {

0 commit comments

Comments
 (0)