Fix check for menu cannot fit on top #5743
Merged
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.
issue #5740
Originally, the check doesn't consider the resolution height, but the resolution height is being used below to determine the style.top. This causes the element to overlap with the parent box, and in turn causes the menu to close onScroll, because of the check here.
Add the height check to the RHS of the > , so the menu won't be placed on the top if it cannot fit.
Taking a step back, I'm not sure why when the menu is placed on top of the cursor, it's
height
length away from the cursor, whereas when the menu is placed below the cursor, it's 0 length away from the cursor. In other words, we could have removed both+ height
on line 519 and- height
on line 522, but I didn't implement that to preserve the original style.Results
Before:
After: