Skip to content

Commit 1d3eb5c

Browse files
committed
fix: Fixed dropdown window position resetting if the distance to bottom of the screen is less than 100 pixels
1 parent eec6fae commit 1d3eb5c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Editor/TypeDropdown/DropdownWindow.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private void OnCreate(SelectionTree selectionTree, float windowHeight, Vector2 w
4141
wantsMouseMove = true;
4242
_selectionTree = selectionTree;
4343
_selectionTree.SelectionChanged += Close;
44-
_optimalWidth = CalculateOptimalWidth(_selectionTree.SelectionPaths); //
44+
_optimalWidth = CalculateOptimalWidth(_selectionTree.SelectionPaths);
4545
_preventExpandingHeight = new PreventExpandingHeight(windowHeight == 0f);
4646

4747
_positionOnCreation = GetWindowRect(windowPosition, windowHeight);
@@ -88,7 +88,14 @@ private Rect GetWindowRect(Vector2 windowPosition, float windowHeight)
8888
// If given less than 100f, the window will re-position to the top left corner. If given 0f on MacOS,
8989
// the window may not appear at all. Thus, the minimal value is 100f.
9090
const float minHeightOnStart = 100f;
91-
windowHeight = windowHeight == 0f ? minHeightOnStart : windowHeight;
91+
windowHeight = windowHeight < 100f ? minHeightOnStart : windowHeight;
92+
93+
float distanceToBottomBorder = EditorDrawHelper.GetMainWindowPosition().yMax - windowPosition.y;
94+
95+
if (distanceToBottomBorder < windowHeight)
96+
{
97+
windowPosition.y = EditorDrawHelper.GetMainWindowPosition().yMax - windowHeight;
98+
}
9299

93100
var windowSize = new Vector2(distanceToRightBorder, windowHeight);
94101

0 commit comments

Comments
 (0)