-
Notifications
You must be signed in to change notification settings - Fork 20
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
Tooltips / Popper support #46
base: main
Are you sure you want to change the base?
Conversation
…used Bootstrap Icons from cards example wip: porting popper to current yew-bootstrap wip: moving things back to the way they were Tooltips: rework docs, add examples Re-export Placement to avoid requiring a direct dependency on popper-rs Add support for tooltips to form controls Add tooltip support to Link Mark tooltips as supported fix Tooltip doctest fix tooltip formatting Make buttons with tooltips different colours, reformat some examples Allow using media queries to selectively enable Tooltip-on-focus support. Ignore synthetic hover events (iOS). Document browser nonsense
…oesnt work on <a>
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.
Please correct the use of the TooltipFocusTrigger
variants in the forms example. Looks like you may have changed the names and missed updating them.
TooltipFocusTrigger::IfNoHover, | ||
TooltipFocusTrigger::IfNoAnyHover, |
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 variants don't exist!
Based on
#45#48This adds support for tooltips with
popper-rs
.Bootstrap tooltips are built with Popper. Both Yew and Popper assume they have complete control of the DOM, so Popper needs some extra wiring to handle the component lifecycle correctly, which
popper-rs
provides.This takes some ideas from
react-bootstrap
's Tooltip implementation, but goes for a slightly simpler model, where Tooltips are dropped into a portal directly (likepopper-rs
' example), and the Tooltip component is responsible for all the event handling (rather thanOverlay
andOverlayTrigger
).To position the tooltip correctly and mark the target element with accessibility attributes, you need to expose a
NodeRef
for each component you want to add a tooltip to. I've exposedNodeRef
s forButton
,FormControl
andLink
.One of the complexities with this is deciding when to trigger the tooltip, which is a problem both
react-bootstrap
and Bootstrap never really solved. By default, this will trigger on focus and on pointer hover. I've added options for selectively disabling triggering on focus, but deficiencies in the Media Queries spec and browser implementations make none of them great options. There are a lot of caveats listed in the docs.Unlike regular Bootstrap, this doesn't support tooltips from
data
attributes.I've added examples using all of those controls, and also a direct
ref=
attribute on a HTML elements.