-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add Tooltip
support to IconButton
#1062
Conversation
This may be a design-level decision but one thing that came up in a convo with @inkblotty was whether tooltips (whether it be What do you think? (I don't want to block this PR so I'd be ok following up on this in a separate PR too) cc: @alliethu |
@khiga8 I think this is a great idea that can scale pretty seamlessly. Also, based on the fact that we now have tooltip types ( |
Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com>
Oh, I 100% agree. I can see two approaches here;
I'd like to go for the second approach, as it will allow us to reduce heterogeneity in implementations sooner, but both can work fine. |
Re: @hectahertz in comment:
Is the |
Re: @inkblotty in comment:
You are 100% right, it is! This definitely makes things easier; we'll still be missing the label on the instances where The proposed API here might not be the best then; maybe a better solution would be to ask for an accessible label only once and control at the framework level how we want to use it (showing it on a tooltip or not, etc.). cc: @alliethu Allowing users granular control of showing a tooltip or not, with custom content different to the aria-label might lead us to unpredictable outcomes. We might not need that level of customization. |
….com/primer/view_components into hectahertz/add-tooltip-to-iconbutton
….com/primer/view_components into hectahertz/add-tooltip-to-iconbutton
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
@hectahertz @khiga8 -- what do we want to do with this? |
@hectahertz is there anything blocking this? |
👋🏻 I can take over here, I'd like to update this with a lookbook preview |
@@ -0,0 +1,4 @@ | |||
<%= render Primer::Beta::BaseButton.new(**@system_arguments) do -%> | |||
<%= render Primer::OcticonComponent.new(icon: @icon) %> | |||
<%= render Primer::Alpha::Tooltip.new(**@tooltip_arguments) %> |
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.
Sorry I just caught that this tooltip element is nested inside the Button
. This should be adjacent to the Button
. Similar problem with Button
component and Link
component.
This current nesting of the tooltip will result in the button (or link) being triggered when one tries to copy the tooltip text and potentially other unexpected behavior.
I think that in the case of tooltip, there will need to be a wrapper div
or span
element over the component and tooltip.
What are you trying to accomplish?
The API of
IconButton
should be updated soTooltip
can be rendered via the component arguments.What approach did you choose and why?
We decided to use a slot to render theTooltip
as it allows for explicit control of the defaults, which we want to ensure proper integration and an accessible outcome. We will follow the same pattern for the rest of the components that integrateTooltip
For example, we settype: :label
as the default, as forIconButton
there's usually no other label.After some discussion in the PR comments, we decided to always include a
Tooltip
onIconButton. The
aria-label` property is always required, and this will improve the experience for sighted users.Hopefully, this approach will simplify the API and will keep the instances of
IconButton
consistent and accessible.Docs
With
aria-label
With
aria-label
andaria-description