Tooltip discovery #3016
zarahzachz
announced in
RFCs
Replies: 2 comments
-
Should evaluate this style when doing Tooltip work |
Beta Was this translation helpful? Give feedback.
0 replies
-
Adding this here because it looks like GitHub didn't automatically pick up on the reference: Discovery branch |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
WNMGDS-2708
This is a discovery to see how far we can get in crafting native tooltips. Spoiler alert: It's pretty dang far!
But first...
Why are we even doing this?
Our current implementation of Tooltip requires the use of at least three separate libraries to handle different functionalities (
react-transition-group
,focus-trap-react
, andpopperjs
). Not only do these libraries add to our bundle size (impacting performance) but they're also ONLY used for this one component. That's a hefty fee for something that's not that reusable.(At this point I should also point out that
react-transition-group
has a comment that it needs to be updated once the React peer dependency's been resolved. This was due to some Astro SSR stuff in #2961)By leaning as hard as we can on native web API, we can eliminate most (if not all) of these additional libraries with minimal impact on UX.
Aside from making sick gains, our Tooltips have historically had... issues. The big ones include:
input type="button"
, but this caveat feels outdated at this point<button>
as a link" so it flows inline with text (buttons can't do this)dialog
tooltips isn't really making these tooltips a dialog elementAs I pointed out earlier, using the native Popover API would result in minimal impact on UX - meaning UX would change, but in a way that solves these UX issues (by standardizing tooltip behavior to open on click [aka, persisting mobile UX across viewports], correctly implementing a11y, and allowing us to officially remove link support from this component).
Watch your six!
The Popover API is easy and straightforward to use, however there are some foot-guns.
popovertarget
) is already being deprecated in favor of a new one (invoketarget
)popovertarget
because it has better browser supportinvoketarget
attribute but I'm not certainpopover
attribute. All specs/instructions say just applying this attribute will create a "popover" element, but I found I still had to assign it a value of "auto" for it to work. I think this is also related to React not understanding the attributes (it kept inferring it was a boolean, which resulted in no tooltips rendering)As far as support goes...
popover
and its associated attributes has pretty good support, with all browsers supporting it (FF being the latest to adopt)Wins
classnames
)Observations and next steps
Observations
It behooves us to re-evaluate our current Tooltip implementation before updating the codebase. I found myself scratching my head at the quantity of customizations we allow for tooltips and wonder if this was a case of over-optimization? I'm not sure how many of these props are actually being used (e.g.,
interactiveBorder
,transitionDuration
,inversed
, etc.), but it seems similar to what we saw when updating our dialogs in that we probably offer way too much stuff. And if we're rolling out a new Tooltip, does it make sense to reimplement stuff we don't need?We should probably lock-in the non-negotiable features (like
maxWidth
, animations, etc.) and just let users adjust the default position (top, bottom, left, right), but that's just my two cents.Next steps
<dialog>
), but with the popover API being attributes and not a new element, maybe not)inert
, so keyboard users get trapped inside the tooltip (with no visual cues like dimmed backdrop indicating its a modal) and screenreader users can access things outside the tooltip with the virtual cursorpopover
outside of a small bug in how popover video works (it continues to play even when dismissed)Beta Was this translation helpful? Give feedback.
All reactions