-
-
Notifications
You must be signed in to change notification settings - Fork 535
Tooltip provider for easily sharing tooltip amongst multiple elements #845
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
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.
The looks nice to me, but only 2 things:
I believe we should use explicit words, like event
instead of e
.
And can you create docs inside docs
folder related to the new possibility of use of the Tooltip, please?
39d1970
to
d3ceb36
Compare
return ( | ||
<span | ||
ref={anchorRef} | ||
data-tooltip-place={place} | ||
data-tooltip-content={content} | ||
data-tooltip-html={html} | ||
data-tooltip-variant={variant} | ||
data-tooltip-offset={offset} | ||
data-tooltip-wrapper={wrapper} | ||
data-tooltip-events={events} | ||
data-tooltip-position-strategy={positionStrategy} | ||
data-tooltip-delay-show={delayShow} | ||
data-tooltip-delay-hide={delayHide} | ||
> | ||
{children} | ||
</span> | ||
) |
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.
After some testing, I've realized cloneElement()
doesn't work super well when passing functional components as children to the wrapper.
Using an actual DOM element (span
seems ok) didn't seem to cause any issues.
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 to me!
Closes #837
Closes #847
Using just
anchorId
without the provider should still work fine.See App.tsx for usage example.
The only major feature missing is using a prop such as
data-tooltip-id
on the anchor element and filtering the event listener and observer subscriptions by the tooltip id.The provider also has to keep the
anchorRefs
andactiveAnchor
separate by tooltip id.Instead of using
data-tooltip-id
, it would also be possible to change the context data signature to something such astooltipId
is used to keep track of which tooltip is being accessed.Without a change like one of these two, the provider only works with one
<Tooltip />
element.If needed, multiple providers (one
<Tooltip />
inside each) can be separately used as a workaround.