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

Responsive tooltips #767

Closed
wants to merge 3 commits into from
Closed

Responsive tooltips #767

wants to merge 3 commits into from

Conversation

simurai
Copy link
Contributor

@simurai simurai commented Apr 25, 2019

This makes the tooltips "responsive". More specifically:

  • By default all tooltips are hidden when the primary input mechanism cannot hover (touch input on mobile, tablets)
  • You can still enable tooltips for touch input with the .tooltipped-touch modifier class.

For example the info icon does nothing except showing more information with a tooltip. In this case it would be ok to use .tooltipped-touch so that you can tap on it also on a phone/tablet to make the tooltip appear.

Screen Shot 2019-04-25 at 10 58 12 AM

Tested on

  • iOS Safari
  • iOS Chrome
  • iOS Firefox
  • Android Chrome
  • Android Firefox

Concerns

We have been testing part of this with https://github.com/github/github/pull/113518. A problem reported by a user is that:

  • a laptop with a touch screen
  • connected to an external monitor (probably not relevant)
  • and using an external mouse

is currently broken. The browser thinks that the "primary" input device is touch so hovering with the mouse does not work. An alternative might be to use any-hover:none instead of hover:none. But that would probably mean that when the user would use the touchscreen, the hover effects are not disabled because the media query only reacts to "what input device is available" and not "what input device is currently in use".

/cc @primer/ds-core


Issue https://github.com/github/design-systems/issues/558
Test on .com: https://github.com/github/github/pull/113518

Copy link
Contributor Author

@simurai simurai left a comment

Choose a reason for hiding this comment

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

Is this a breaking change? Kinda... but it could also be considered fixing a bug on mobile (patch). And adding a new modifier class (minor). Anyways, when shipping this on .com, we would have to add .tooltipped-touch to all these "click icon to get more information" for users that are on a touch device and visit the "Desktop version".

//
// Hide tooltips when primary input mechanism cannot hover (default)
// Enable tooltips for touch input with .tooltipped-touch
@media (hover: none) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is also the any-hover media query which might be useful for these hybrid devices (laptops that have a touch screen and mouse). But I don't have any device to test that. 😉 Also not sure if "One or more available input mechanism" is that helpful, instead it should be "the currently in use input method" so that you can switch between a mouse and touch screen whenever. 🤔

// Hide tooltips when primary input mechanism cannot hover (default)
// Enable tooltips for touch input with .tooltipped-touch
@media (hover: none) {
.tooltipped:not(.tooltipped-touch):hover {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is .tooltipped-touch a good modifier class name? Or should it be more descriptive .tooltipped-show-on-touch .tooltipped-force-hover???

@jonrohan
Copy link
Member

I pulled this change into https://github.com/github/github/pull/113518 for a bug fix

@simurai
Copy link
Contributor Author

simurai commented Apr 30, 2019

I'm still not too sure about the .tooltipped-touch class to opt-in. And since https://github.com/github/github/pull/113518 is currently being tested, I'll move this back to in progress.

@koddsson
Copy link
Contributor

koddsson commented Mar 5, 2021

I'm still not too sure about the .tooltipped-touch class to opt-in. And since github/github#113518 is currently being tested, I'll move this back to in progress.

What's the status of this now that github/github#113518 is merged?

@simurai
Copy link
Contributor Author

simurai commented Mar 8, 2021

What's the status of this now that github/github#113518 is merged?

We haven't really made a final decision. I think one problem with relying on @media (hover: none) is that there are hybrid systems. Like a laptop can have a touch screen and a mouse at the same time and as far as I know, the browser doesn't switch the media query in real time. Also lately iPads got better mouse input support.

I think the better options moving forward is:

  • Not use hover for anything important.
  • Use hover only as a visual guide, e.g. if a row is hovered or not.
  • Use hover only as an additional shortcut when also providing the same functionality for non-hover input. For example it's ok to make a button appear on hover, if there is also an "edit" mode that makes the button appear.

@koddsson
Copy link
Contributor

koddsson commented Mar 8, 2021

👍🏻 on avoiding hover. Seems like a pain for accessibility and touch screen users. Maybe we can file a ADR?

Base automatically changed from master to main March 26, 2021 00:50
@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 May 26, 2021
@github-actions github-actions bot closed this Jun 2, 2021
@github-actions github-actions bot deleted the tooltips branch June 2, 2021 23:54
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.

3 participants