-
Notifications
You must be signed in to change notification settings - Fork 223
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
Use Popper for position calculations #181
Conversation
}); | ||
} | ||
|
||
[ |
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.
these are a bit different now in the "offsetBefore" and "offsetAfter" cases
arrowPosition: { top: 100 }, | ||
}, | ||
offsetBefore: { | ||
position: { left: 50, top: 0 }, |
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.
new
{ | ||
placement: 'left', | ||
noOffset: [50, 200, undefined, '50%'], | ||
offsetBefore: [-200, 50, undefined, '0%'], |
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.
corresponding old...
though note that the target position is a bit different now
the old impl would only apply the padding to cross-axis positioning. this on the other hand applies the padding to same-axis, mostly
Hmm, this makes the R-B docs page look weird even with fixes. Meh. |
Browser support? Also what is the motivation for this? I'm a big fan tho I thought we were holding off b/c of various IEs |
Looks like IE10+: https://saucelabs.com/beta/builds/07fe610fcdca470f8ca45384a15409ff No particular motivation... just saw we had a lot of position issues/PRs open, and wondered if we could scrap all of our own code. It was harder than expected and I got pretty carried away, but that happens. Unfortunately this might not be viable – Popper takes into consideration e.g. margins on the popped elements, while TWBS3 popovers (and maybe tooltips as well?) are explicitly built with the assumption that such margins are ignored. |
Hi, |
@taion is this designed to account for TWB v3 reqs? I'd say we add this but ignore the v3 stuff and keep both the new and old Position around for v3 legacy but retire it here. v4 bootstrap needs the popper version anyway |
This won't work with TWBSv3 without horrible hacks because of the way TWBSv3 handles margins and such. You proposed moving the TWBSv3-compatible version of this into React-Bootstrap, which sounded like a good idea at the time. |
I'm hitting a point just in our own code where I jsut want to use popper and not the default bootstrap stuff, so i'm a bit anxious to move on that. I think we just freeze the position component where it is and either move it to RB or keep it here as PositionLegacy, and move forward with the unhacky popper implementation. But importantly we don't try and make popper work with bootstrap v3 |
I'd move it to R-B. It's really very TWBSv3-specific, and I don't think it works too well for other cases. Or anyway the Popper-based version is more generic. |
It's worth considering whether we want to use react-popper, though: https://github.com/souporserious/react-popper The API is pretty different from what's here, but... well, it's there. |
That works for me, I'll move it over. Does this need any unhacking, or you think its good to go as a general implementation over Popper? |
Config-wise, I tried to get something that pragmatically matched how TWBSv3 worked, with things like: https://github.com/react-bootstrap/react-overlays/pull/181/files#diff-b7dd97a1efefd56a539d6f75fcd04a7bR209 If we're not worrying about TWBSv3-compat any more, then I'd switch to either using better defaults, or to exposing those config flags. |
Any chance we would be getting edge detection for free by using popper/react-popper here? |
Yes. |
Any progress on this? I'd love to help out but i'm not quite sure where this PR stands? |
Next step is to move the legacy implementation into React-Bootstrap, because this doesn't work well with TWBSv3. |
IMO it would be nice not to have to bring in another large dependency just for positioning. Is it really needed? What do we get that we wouldn't get from e.g. #175? |
Well, it's 6 kB minified + gzipped, so not that big? Also just more powerful/flexible. |
6K is pretty big for what it is doing I think. What actual features does it provide that you're exposing in react-overlays other than fixing cross-axis positioning? |
we are thinking about exposing all the features, thats sort of the point and benefit. :) In any case this is likely to happen for bootstrap v4 because upstream bootstrap uses it |
I'd love to merge it asap, but I don't have time at the moment to adjust the PR here per the above convo and I'm guessing @taion may be in a similar boat |
Also is this backwards compatible with the existing Position component? If not, what is the migration path? Major version bump? We could merge #175 in the mean time which is backwards compatible... |
It doesn't need to be backwards compatible here. But we need to move the existing Position component to react-bootstrap per the convo above |
How will that work since |
@taion and @jquense would it be possible to merge #175 for the time being and save the popper integration for a larger version bump? I'm in the same boat as @devongovett – need some cross-axis positioning functionality. p.s. Thanks for the awesome library + work so far!! |
@taion yo can we just merge this? |
Well, no, because package-lock.json has a merge conflict :p |
Oops finger slipped. I can look for some time to work on this though. |
Thank god for the finger slip! I thought for a moment this was dead 😛 |
@taion imma merge this later today |
Sounds good, do you need anything from me? |
It'd be excellent if you had a moment to see if this properly sets us up for the v4 dropdowns. |
There's a functional change here in same-axis positioning when the positioned element is about to escape. Otherwise I think everything mostly works the same. There's a debounce on the initial update, but that's not really noticeable.
I changed the API a bit to make it maybe cleaner. Plus now I explicitly hide the positioned element when we don't have a position for it.
We're not really exposing all that Popper is offering, but I'm okay with that. This closes a lot of the positioning issues on our end.
Closes #52
Closes #135
Closes #175
Closes #176
Closes #178