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

Hover state becomes stuck after tap on iOS #1827

Open
FlyersPh9 opened this issue Feb 7, 2024 · 6 comments
Open

Hover state becomes stuck after tap on iOS #1827

FlyersPh9 opened this issue Feb 7, 2024 · 6 comments
Labels
bug Something isn't working css Needs change in css package

Comments

@FlyersPh9
Copy link
Collaborator

Describe the bug (actual behavior)

When tapping a button on iOS, the button gets stuck in the :hover state. This likely effects all components that have a :hover state & after interaction you stay on the same page.

Reproduction

  1. Open https://itwin.github.io/iTwinUI/css/button.html on iOS.
  2. Tap button.

Additional information

I discovered this bug while working on a personal project and learned that this solution fixes the issue:

@media (hover: hover) {
  button:hover {
    border: 3px solid green;
  }
}
@FlyersPh9 FlyersPh9 added the bug Something isn't working label Feb 7, 2024
@AdamMeza-Bentley

This comment was marked as spam.

@FlyersPh9
Copy link
Collaborator Author

While working on #1919 I was using @media (hover: hover) within .iui-field & discovered that CSS test images were failing to show the hover state on <button>. After some investigation with @rohan-kadkol we realized that removing @media (hover: hover) fixed the test image failures. This was a bit surprising because browser support for this media query seems to be pretty good.

@mayank99
Copy link
Contributor

mayank99 commented May 2, 2024

We might want to use any-hover instead of hover. The latter only takes into account the primary input device, which is arbitrarily decided by the operating system. See https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-whats-the-primary-input

The downside is that we'll have some false positives on hybrid/multi-modality devices, but it would still be better than the current situation.

@FlyersPh9
Copy link
Collaborator Author

@mayank99, what would be the best way to handle situations like this?

&:where(:hover, :active) {
  … 
}

Duplicate the CSS?

@media (any-hover: hover) {
  &:where(:hover) {
    … 
  }
}

&:where(:active) {
  … 
}

@FlyersPh9
Copy link
Collaborator Author

Also @media (any-hover: hover) is failing to work in our CSS BackstopJS image tests. 😞

@mayank99
Copy link
Contributor

Duplicate the CSS?

Yeah, I think duplication should be fine, as long as :active provides a real benefit on touch devices.

Also @media (any-hover: hover) is failing to work in our CSS BackstopJS image tests. 😞

Maybe we should consider switching away from backstop to cypress or playwright, if it works better in the latter.

@FlyersPh9 FlyersPh9 added the css Needs change in css package label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working css Needs change in css package
Projects
None yet
Development

No branches or pull requests

3 participants