Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

micolous
Copy link
Contributor

@micolous micolous commented Sep 8, 2024

Based on #45 #48

This 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 (like popper-rs' example), and the Tooltip component is responsible for all the event handling (rather than Overlay and OverlayTrigger).

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 exposed NodeRefs for Button, FormControl and Link.

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.

…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
@micolous micolous changed the title Draft: Tooltips / Popper support Tooltips / Popper support Jan 17, 2025
@micolous micolous marked this pull request as ready for review January 17, 2025 06:57
Copy link
Owner

@isosphere isosphere left a 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.

Comment on lines +445 to +446
TooltipFocusTrigger::IfNoHover,
TooltipFocusTrigger::IfNoAnyHover,
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants