-
Notifications
You must be signed in to change notification settings - Fork 26
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(tooltip): expose Popper.js modifiers #1054
Conversation
20b156a
to
71ad8b9
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.
Thanks 👍
Interesting. So we are are fine with "leaking" what our component library uses underneath to the consumers. As an alternative to wrapping that API in a minimal way to encapsulate it? |
Ah okay cool so it was a concern before. Curious now (I trust your judgement) what is the exact case where we need more control over the positioning? |
@tdeekens I don't like this leaking as well, but as @montezume said, looks like it the least pain in the ass for everyone. My specific use-case, why I need it is showing tooltip inside scrollable container, so that it will be shown outside of that container. Looks like the popper is smart enough to figure out that element with a tooltip is a child of scrollable container and tries to keep it inside of parent's boundaries. I created a branch with a story reproducing my use-case: https://github.com/commercetools/ui-kit/blob/pa3-tooltip-issue/src/components/tooltip/tooltip-bug.story.js Too save you some time with running this example on your machine, let me provide some screenshots, illustrating the intent. This is a simplified layout we have in one of the pages of MC: Right column is considered a scrollable container by Popper. What I want to see when hover on the button: And I didn't find a way to achieve this without providing way to set |
Thanks for the illustration. Was easy to grasp the issue with it! Generally I agree that exposing poppers API through our Tooltip implementation is the least hassle. We just have to buy into the obvious trade-off that:
Accepting those drawbacks comes at the benefit of being less a pain of adding it now. What I am generally wondering is:
|
Yeah, I guess just exposing the required modification makes sense for now. Then if we make changes to the underlying implementation of |
Popper.js, which our Tooltip relies on, provides a powerful way of altering tooltip behaviour by using so called modifiers: https://popper.js.org/popper-documentation.html#modifiers
In some tricky cases they can really help properly place your tooltip. Instead of extending Tooltip's API case-by-case when facing them (at the moment I need a way to provide
preventOverflow
modifier to achieve proper positioning of a tooltip in MC), I suggest just expose all of them at once.By doing this, we are paying a price of leaking internal implementation details of Tooltip component, but on the other hand leveraging lot of power of the underlying lib.