Skip to content

Commit aef47cb

Browse files
committed
fix: try placing info box above options box when no place available
1 parent 287182c commit aef47cb

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,8 +2059,26 @@ function RemoteFunctions(config = {}) {
20592059
topPos = offset.top;
20602060
leftPos = leftSideLeft;
20612061
} else {
2062-
// Last resort: Above element (above options box)
2063-
// Will be positioned above options box by checking overlap later
2062+
// Last resort: Try above options box, then above element
2063+
// First, try to position above options box
2064+
let aboveOptionsBoxPos = null;
2065+
2066+
if (_nodeMoreOptionsBox && _nodeMoreOptionsBox._shadow) {
2067+
const optionsBox = _nodeMoreOptionsBox._shadow.querySelector('.phoenix-more-options-box');
2068+
if (optionsBox) {
2069+
const optionsOffset = _screenOffset(optionsBox);
2070+
aboveOptionsBoxPos = optionsOffset.top - boxDimensions.height - MARGIN;
2071+
2072+
// Check if it fits in viewport
2073+
if (aboveOptionsBoxPos >= viewportTop + MARGIN) {
2074+
topPos = aboveOptionsBoxPos;
2075+
leftPos = offset.left;
2076+
return {topPos, leftPos};
2077+
}
2078+
}
2079+
}
2080+
2081+
// If above options box doesn't fit, try above element
20642082
topPos = offset.top - boxDimensions.height - MARGIN;
20652083
leftPos = offset.left;
20662084

0 commit comments

Comments
 (0)