-
Notifications
You must be signed in to change notification settings - Fork 59
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
fix: contextual menu container overflow #1000
fix: contextual menu container overflow #1000
Conversation
2517424
to
6bb3295
Compare
6bb3295
to
8f23d98
Compare
- fix dropdown props being passed incorrectly to the wrapper - add isEnabled option to useOnEscapePressed and useClickOutside
8f23d98
to
809fc3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good functionality wise. Two nitpicks about code style / simplifications. Feel free to address or keep as is.
Edit: I don't have a way to test this in other projects without a full release. But I won't expect this to break anything.
aria-label={Label.Dropdown} | ||
ref={dropdown} | ||
style={{ | ||
...(positionStyle as React.CSSProperties), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to cast here.
...(positionStyle as React.CSSProperties), | |
...positionStyle, |
Hi @petermakowski, this was using a portal so that it could escape its container to prevent issues such as Any ideas for mitigating that issue? |
@huwshimi Thanks for chipping in. Very good point, clearly I was missing some context here. I intended for this to be fixed by removing In the examples that you pasted specifically this can be worked around by using automatic positioning and displaying the menu at the top of a trigger when not enough space is available at the bottom (the approach that we're exploring in MAAS currently). Having said that, it's a big change in approach and something that not all teams may want to adopt. I'll give this some more thought. Marking this as do not merge for now. |
Thanks Peter, we've definitely had cases in the past where we couldn't control the overflow which is why we ended up using portals, but maybe there's another approach we haven't considered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaving a "Request changes" here so that we remember this needs to address the overflow: hidden
hidden issue as discussed.
- update react-useportal to v1.0.19 - add options to useListener
@huwshimi This is ready for another review. I reverted changes related to relative positioning, keeping node position in sync with the container is now handled similarly to window resize. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great now, thanks for the improvement @petermakowski!
Done
This pull request fixes the menu position when scrolling in overflowing containers.
useListener
hookwrapperClassName
tocontextualMenuClassName
for clarityScreenshots
Before
After
QA
QA steps
Go to the overflow example
Ensure that once you open the dropdown and scroll, menu position is in sync with the toggle
In the props control, set autoAdjust to false and position to right
Open the dropdown menu
Menu position should reflect the value of the prop (right)
Close the dropdown
Set autoAdjust to true
Open the dropdown
Menu position should be adjusted on open (and set to the left)
Link react-components locally with your project and ensure that contextual menus work as expected
Fixes
Fixes: https://warthogs.atlassian.net/browse/MAASENG-2407
#687
#769