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

Add Tooltip support to IconButton #1062

Merged
merged 33 commits into from
Aug 1, 2022
Merged

Conversation

hectahertz
Copy link
Contributor

@hectahertz hectahertz commented Mar 17, 2022

What are you trying to accomplish?

The API of IconButton should be updated so Tooltip can be rendered via the component arguments.

What approach did you choose and why?

We decided to use a slot to render the Tooltip 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 integrate Tooltip

For example, we set type: :label as the default, as for IconButton there's usually no other label.

After some discussion in the PR comments, we decided to always include a Tooltip on IconButton. 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

Screen Shot 2022-03-18 at 17 49 47

With aria-label and aria-description

Screen Shot 2022-03-18 at 17 49 54

Screen Shot 2022-03-18 at 17 58 45

Screen Shot 2022-03-18 at 17 58 58

Screen Shot 2022-03-18 at 17 59 03

@hectahertz hectahertz requested a review from khiga8 March 17, 2022 16:15
@hectahertz hectahertz self-assigned this Mar 17, 2022
@hectahertz hectahertz requested review from a team and manuelpuyol March 17, 2022 16:15
app/components/primer/icon_button.rb Outdated Show resolved Hide resolved
app/components/primer/icon_button.rb Show resolved Hide resolved
@khiga8
Copy link
Contributor

khiga8 commented Mar 17, 2022

This may be a design-level decision but one thing that came up in a convo with @inkblotty was whether tooltips (whether it be type: :label or type: :description) should always be set on icon-only buttons so that sighted users have more context. Here's a related audit issue.

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

@alliethu
Copy link
Contributor

This may be a design-level decision but one thing that came up in a convo with @inkblotty was whether tooltips (whether it be type: :label or type: :description) should always be set on icon-only buttons so that sighted users have more context. Here's a related audit issue.

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 (label/description), it seems like a good opportunity to establish guidance for how to structure the tooltip language across the system.

Co-authored-by: Kate Higa  <16447748+khiga8@users.noreply.github.com>
@hectahertz
Copy link
Contributor Author

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

Oh, I 100% agree.

I can see two approaches here;

  • Making it required now and fixing those instances as we port them to this implementation.
  • Keeping it optional for now, porting all instances to use it, and then introducing the restriction and fixing the missing labels.

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.

@inkblotty
Copy link
Contributor

Re: @hectahertz in comment:

  • Making it required now and fixing those instances as we port them to this implementation.
  • Keeping it optional for now, porting all instances to use it, and then introducing the restriction and fixing the missing labels.

Is the aria-label or similar prop already required? If so, I don't think we would need to add a new prop for it. We could reuse the existing accessible name. If it isn't required, that's a larger discussion.

@hectahertz
Copy link
Contributor Author

Re: @inkblotty in comment:

Is the aria-label or similar prop already required? If so, I don't think we would need to add a new prop for it. We could reuse the existing accessible name. If it isn't required, that's a larger discussion.

You are 100% right, it is! This definitely makes things easier; we'll still be missing the label on the instances where IconButton is not being used yet, but it should not be such a big issue.

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.

@hectahertz hectahertz temporarily deployed to github-pages May 13, 2022 13:59 Inactive
@hectahertz hectahertz temporarily deployed to github-pages May 17, 2022 08:44 Inactive
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale Automatically marked as stale. label Jul 16, 2022
@inkblotty inkblotty removed the Stale Automatically marked as stale. label Jul 18, 2022
@inkblotty
Copy link
Contributor

@hectahertz @khiga8 -- what do we want to do with this?

@khiga8
Copy link
Contributor

khiga8 commented Jul 21, 2022

@hectahertz is there anything blocking this?

@jonrohan
Copy link
Member

👋🏻 I can take over here, I'd like to update this with a lookbook preview

@jonrohan jonrohan assigned jonrohan and unassigned hectahertz Jul 28, 2022
@jonrohan jonrohan temporarily deployed to github-pages July 29, 2022 00:01 Inactive
@jonrohan jonrohan temporarily deployed to github-pages August 1, 2022 20:32 Inactive
@jonrohan jonrohan enabled auto-merge (squash) August 1, 2022 21:00
@jonrohan jonrohan temporarily deployed to github-pages August 1, 2022 21:04 Inactive
@jonrohan jonrohan merged commit 4b673a6 into main Aug 1, 2022
@jonrohan jonrohan deleted the hectahertz/add-tooltip-to-iconbutton branch August 1, 2022 21:12
@primer-css primer-css mentioned this pull request Aug 1, 2022
@@ -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) %>
Copy link
Contributor

@khiga8 khiga8 Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonrohan

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.

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

Successfully merging this pull request may close these issues.

7 participants