New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Popover] Warn when the height of the Popover is too tall #8839
Conversation
I don't get the extra logic. cc @eyn |
Hi, the logic is, The issue I faced is that, I have a select with many items (100+) and when you open it, the dropdown has the top set as -9900px and it clips most of the dropdown. This is a simplified version of the code, I used the one with the || and sqrt to keep the code coverage intact because the codecov kept complaining and I was too lazy to change the tests :).
What the sqrt does is that, if the top is below marginThreshold, the marginThreshold - top will be a negative value and sqrt of that will be a NaN and Nan || 0 will give 0 (hence don't change the top). But if the marginThreshold - top is positive (i.e. top is above marginThreshold) it will move the top to the marginThreshold level. Hope this helps. |
@amilagm Thanks for the extra details. Do you have a reproduction example? Or a failing test case? I don't think that we should rely on the |
I agree with the sqrt error but I think it will be insignificant, or you can just use normal IF logic but it requires test changes to improve coverage, that's why I did not go ahead with that. |
Thanks for the extra screenshots.
It's not because the test coverage doesn't change that we don't require all bug fixes to be tested 😁 to prevent regressions. |
@amilagm I'm finishing this PR. |
f0958f6
to
cc3b2c6
Compare
@amilagm I have reverted your changes and added a new warning. The Popover wasn't designed to goes off screen. Worse, once an element is off screen it can't be interacted with. We block the scroll as soon as the Popover is opened. |
cc3b2c6
to
a44ac38
Compare
@amilagm Thanks for raising this concern! |
@oliviertassinari Thanks, Sorry if I'm mistaken, but wouldn't it still move the popover up ? I know you will get a warning, but is there anyway for the user to prevent the control from moving past the viewport top ? The problem I was facing was a Select control with too many items in that and I don't have control over the number of items. So ideally I need it to start from the top of the page. I can control the max height and scroll via external css. |
@amilagm Yes, it will. You can prevent the behavior by adding a max-height on the container. We have a demo in the documentation: |
@cameronb23 This is a regression in beta.19. It was fixed in the v1-beta branch. Hold on for a new release. |
If the popover height is larger than the viewport, the top of the popover is set to a negative value and thus clips it.