-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: referenceNode support for reference objects (closes #800) #801
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
feat: referenceNode support for reference objects (closes #800) #801
Conversation
Sigh! IE11. Will boot up a VM and take a look. |
It's been a while since last time I checked, but I think the idea was to allow the consumer to define their own object reference parent node to improve flexibility? |
@FezVrasta Yeah, I did see some old comments indicating that would be a desirable approach, however unfortunately it doesn't work that way, at least not at present: You'd also need to implement e.g. ... However, this PR was actually my second pass at resolving this issue. My first attempt is here. I'll happily submit that as an alternate resolution, particularly if it means I don't have to touch IE11 😉 My original approach is entirely non-breaking as the alternate behavior is only triggered if a newly defined property exists. If you'd like me to submit it as a PR, just let me know. |
referenceNode can be specified to better facilitate non-fixed positioning when a popper's reference is a "reference object". In particular, reference objects can now return coordinates in "client-space" (i.e. getBoundingClientRect) and popper will calculate positioning using the specified referenceNode rather then falling back to the documentElement. Consequently, enabling Popper.enableEventListeners() will now work as expected, automatically updating the popper position, when scrolling and resizing the browser window; assuming a referenceNode has been provided.
Thanks, your other attempt seems cleaner to me, I'd like to merge it if you decide to send a PR. |
c45b6b6
to
16172fd
Compare
@FezVrasta Seems as other people have already referenced this PR. and I'm still resolving the same issue, I've just pushed it here. |
Whoops, hold up. Realised there's a couple of issues - not with the functionality, but code structure and comments i.e. getReferenceNode isn't re-exported from utils. Will fix that right now... |
Don't worry about the utils re-export, that's a deprecated feature anyways |
@FezVrasta No problem. If you don't have any other feedback, then please go ahead and merge this as is. I was going to change the docs for Additionally there's the whole So if it's okay with you, I'll leave those sorts of decisions to you 😄 Obviously, feel free to make any changes you desire post-merge. |
Yeah type annotations aren't the best in v1... v2 is written from the ground up with Flow so this should get fixed if I'll ever manage to complete it. |
Is it possible to release 1.16.0 with this? |
ping @FezVrasta New release for this feat would be great |
Fix for #800
Basically popper.js was assuming popper's were always in global (client) coordinates when a reference object was provided instead of a reference element.
We now detect reference object usage and calculate coordinates relative to the popper's parent node.There is now an additional property,
referenceNode
, which can be provided on a "reference object". popper.js will now position relative to this node when the property is specified.