-
Notifications
You must be signed in to change notification settings - Fork 1.3k
@react-aria/overlays - Fix overlay position clamping #3756
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
Conversation
🚀 |
GET_BUILD |
Build successful! 🎉 |
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.
Thanks for having a go at this!
// button bottom touching overlay bottom | ||
let bottomsTouchPosition = childOffset[crossAxis] + childOffset[crossSize] - overlaySize[crossSize]; | ||
// button top touching overlay top | ||
let topsTouchPosition = childOffset[crossAxis]; |
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'm a little worried about this, but potentially I'm just not holding the math in my head correctly because I've been testing locally and it appears to be correct.
It used to be that the min/max positions had to do with the center of the target and the top/bottom of the overlay, but now they'd be in relation to the top of the target and bottom of the target with the top and bottom of the overlay respectively?
I tried doing the storybook path=/story/dialogtrigger--crossoffset-examples
and it looks right. I also tried it with much larger targets (UNSAFE_style height/width on the buttons) and it also still seems correct. Can you clarify the change a bit more?
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.
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.
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.
.add('document.body container top', () => <Trigger withPortal placement="top" />) | ||
.add('positioned container bottom', () => <Trigger withPortal={false} placement="bottom" />) | ||
.add('positioned container top', () => <Trigger withPortal={false} placement="top" />) | ||
.add('buttonWidth=500 document.body bottom start', () => <Trigger withPortal buttonWidth={500} placement="bottom start" />) |
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.
can you include a screenshot of before and after? just want to know what this is verifying
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.
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.
Thanks so much for drawing those up, that really helped me understand the issue and what you were doing to solve it. This makes sense to me and does seem like a change we want. I've run into it in another bit of code of I've been working on and this would solve it.
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.
Tested all the places where I expected issues and this works great. Thanks!
Love the diagrams!
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.
LGTM, the calculations check out to me and the stories seem to reflect that
Just a heads up, we have been discussing this new behavior amongst the team and haven't quite settled on what we want as the final behavior (in particular for the case where the overlay is smaller or equal to the trigger's size). We'll be reverting these changes for now so they won't be available in the release going out this month, but we plan on returning to this in the new year. |
Thanks for the heads up. I was expecting the same/similar behavior to popper js, which was a dependency I removed in favor of react aria's positioning. Let me know if I can clarify anything |
@filipw01 We did some more testing and these are the two cases which we wanted to fix/discuss:
Lemme know if you have any thoughts on the above and/or are interested in digging into these cases further. If not, that is perfectly fine, the team will see if we can address these cases in the coming sprints. |
@LFDanLu I'm still interested, I will take a closer look this week and let you know what I think about these cases |
I think there are three main options here.
There are also possible hybrids like
I don't have a preference, and I don't know how hard it is to implement each option. Let me know what you think about these approaches. |
@filipw01 Preliminary discussions with the team has us leaning towards option 2. One tricky thing is that we don't have the arrow's information (width, etc) available in I'll keep you posted with any further updates |
@filipw01 The team has discussed this some more and would like to add an additional detail. We'd still like to go with option 2, but would like the arrow to always point to the center of the overlay if possible. Let us know if you have any thoughts on the above |
@LFDanLu Just so we're clear. You expect something like this, right? |
@filipw01 Correct! |
Closes: relates to #1297
✅ Pull Request Checklist:
📝 Test Instructions:
Open newly created story in UseOverlayPosition story and play with different positions and offsets. More details about the issue that was fixed here #1297
🧢 Your Project:
https://www.chilipiper.com/