@media hover query

Discussions about the development and maturation of the platform code (UXP).
Warning: may contain highly-technical topics.

Moderators: trava90, athenian200

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2518
Joined: 2018-05-05, 13:29

@media hover query

Post by vannilla » 2026-01-18, 21:48

(I'm not sure which place is the best one for this report, feel free to move it as appropriate.)

I was not aware about it at all, but there is a hover @media query "widely available" since 2018: https://developer.mozilla.org/en-US/doc ... edia/hover
It seems the browser does not support it.

From what I understood, it appears to be a mobile-centric query: mobile devices cannot hover in the traditional sense but only through hacks (e.g. a middle way between a "left click" tap and a "right click" long tap); with this query a website can know if hovering is a valid user interface action.

I've met this issue on a singular place which made me aware about its existence and the admin agreed to revert it for the time being, so the compatibility issue has been "solved" in the immediate moment and it's not important to implement it soon, but I thought I'd report about it anyway in case our friendly frameworks one day discover it (and make it available through the forum search).

Since UXP is mainly a desktop platform I think it can be as simple as making this query always active, but of course it needs to be parsed and evaluated and I don't know how much work it takes.

User avatar
Moonchild
Project founder
Project founder
Posts: 38816
Joined: 2011-08-28, 17:27
Location: Sweden

Re: @media hover query

Post by Moonchild » 2026-01-18, 22:16

"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
Moonchild
Project founder
Project founder
Posts: 38816
Joined: 2011-08-28, 17:27
Location: Sweden

Re: @media hover query

Post by Moonchild » 2026-02-07, 12:07

I'm working on getting something for this in but because it seems to be rarely-used on websites that aren't completely mobile-only focused, I don't really have a test case for this which would be good to know if I'm actually fixing compat issues.
Do you have anywhere I can easily test this?
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2518
Joined: 2018-05-05, 13:29

Re: @media hover query

Post by vannilla » 2026-02-07, 14:41

Unfortunately(?) the site that had it reverted the change, all I can point to are the examples on MDN which I'm aware are not ideal to check for every corner cases.
Maybe I can find the old commit for that site (it's open source) and extrapolate the intended behaviour from there, but it will take a while.

User avatar
Moonchild
Project founder
Project founder
Posts: 38816
Joined: 2011-08-28, 17:27
Location: Sweden

Re: @media hover query

Post by Moonchild » 2026-02-07, 15:36

I found https://patrickhlauke.github.io/touch/p ... over/which seems to be a good enough test at least for the base implementation, so I'm using that for now.
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite