Skip to content

hoverOnlyWhenSupported doesn’t work with iPad trackpad #11109

Closed
@patrikholcak

Description

@patrikholcak

What version of Tailwind CSS are you using?

v3.2.1. I checked the code and there have been no changes (master)

What build tool (or framework if it abstracts the build tool) are you using?

Tailwind play

What version of Node.js are you using?

What browser are you using?

Safari 16.4

What operating system are you using?

iOS 16.4

Reproduction URL

https://play.tailwindcss.com/p2MO5uc3gD

Describe your issue

#8394 introduced a new future flag hoverOnlyWhenSupported, which uses hover and pointer media to get rid of sticky hovers on touch devices. Both pointer and hover only test for the primary input. This means a touch device with trackpad connected (eg. iPad with Magic Keyboard) doesn’t show any hovers when using the trackpad when this flag is enabled.

Using any-hover and any-pointer should solve that issue, however simply changing the value might not be the best option, as some people could want the current behaviour. There also might be some edge cases I’m not seeing right now — likely some hybrid device which does some weird stuff in tablet vs laptop mode, etc. which could result in sticky hovers even with the flag enabled…

A viable option might be to have control over which property is used, eg.

future: {
  hoverOnlyWhenSupported: "primary" | "any" | false,
}

Anyway, this is reproducible in XCode Simulator (click the "Capture pointer" button in top right) using the play link above. Here’s also a great page which shows the difference between the selectors and shows you what media your device currently matches:
https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/


I tried to solve this locally by first disabling the hover core plugin and wasn’t able to:

corePlugins: {
  hover: false,
},

Looks like it’s not even specified in CorePluginList type. But then I tried simply adding a new custom hover variant and it allows me to override the core plugin, css output looks 👌 too — https://play.tailwindcss.com/TT1IC2V7xN

Seems like this could be a viable short term solution for me, but it just doesn’t feel right…

plugins: [
  function ({ addVariant }) {
    addVariant('hover', '@media (any-hover: hover) and (any-pointer: fine) { &:hover }')
  }
]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions