Popover: Controlled height based on size of contents #2562
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.
Summary
This change handle and fix the following error, reported to us by this thread:
"When we have more content inner dropdown children than the viewport height supports and the anchor is positioned on second half (bottom half) of screen, the initial elements is not accessible"
The images below provide you the bug view:
BUG's reproduction: https://codesandbox.io/s/dropdown-size-error-3jo09u
Gestalt component involved
Solution
We fix the max height of children's Popover content to 90% of the viewport's vertical size. If the viewport contains a
ScrollBoundaryContainer
component, we use the height of this component to set the max height of popover content. In other words, the Popover max size is90% screen height
or90% of ScrollBoundaryContainer height
.The second solution part is "top positioning" If we have a negative top value, which means if the
Controller
sets the top with a negative value (< 0), the popover commonly will not allow access to part of its internal content. In front of this case, we set the top's value as5%
of the height available (following the height decisions explained above).More about Controller and Popover structure here
To understand better each concept, please read the comments attached on code.
How to test it?
/web/dropdown
4. Expand the code example; 5. Use one the following codes to test the solution:
Example 01
Example 02
Links