Fix popups going off screen vertically (upwards) #220
+7
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Imagine a popup menu being 60% as tall as your screen real estate. If you open this popup in the (vertical) center of the screen, the current algorithm to place it will recognize that there isn't enough space underneath the click position to display it (50% + 60% > 100%).
The popup is then shown above the click position without any further checks, despite there not being enough space available there, either. (50% - 60% < 0%)
This PR slightly modifies this behavior by adding a second check: If there isn't enough space above the click position, the menu is moved down as far as necessary to display it. (At this point in the code we know that the menu is small enough to fit on the screen, so we only have to consider where - not whether - to place the menu.)
This change affects all popup menus (e.g. on buttons and comboboxes), but it doesn't fully fix this issue when observed on comboboxes, since they might be parented in more complex ways, which affects where their popup-menus can be shown.