Skip to content

[mediaqueries-4] any-hover can't be used to detect mixed hover and non-hover capable pointers #841

Closed
@patrickhlauke

Description

@patrickhlauke

Relates to https://drafts.csswg.org/mediaqueries-4/#any-input

A more focused successor to #737, only covering any-hover (as I can now rationalise better why any-pointer behaves the way it does, which I tried to more explicitly point out in #842)

any-hover, as currently specified, only evaluates to none when ALL detected pointing mechanisms are non-hover-capable. This currently makes it impossible to query specifically if some, but not all, of the pointing mechanisms is non-hover-capable (or conversely, to test if ALL detected pointing mechanisms are hover-capable)

Assuming two or more pointing devices are present, you can currently only test:

  • at least one of the devices is hover-capable - any-hover:hover will evaluate to true (and currently, regardless of whether any of the other pointing devices is non-hover-capable, any-hover:none will be false)
  • none of the devices is hover-capable - any-hover:hover will evaluate to false, any-hover:none evaluates to true

Scenarios that can't be tested (as they return the same as the "at least one..." scenario above):

  • at least one, but /not/ all, device is non-hover-capable - any-hover:hover will evaluate to true, any-hover:none will evaluate to false
  • /all/ devices are hover-capable - any-hover:hover will evaluate to true, any-hover:none will evaluate to false

As the UA should be able to ascertain the total number of pointing devices (since it needs to know this in order to properly evaluate any-pointer, presumably), it should be possible (and not require some special "we need to define what an input is" additional consideration, which was the major argument against #737) to also change when any-hover:none evaluates as follows:

  • if ANY inputs are present that are non-hover capable, any-hover: none should evaluate to true
  • if ANY inputs are present that are hover capable, any-hover: hover should evaluate to true
  • if ALL inputs that are present are non-hover capable, any-hover: none should be true and any-hover: hover should be false
  • if ALL inputs that are present are hover capable, any-hover: none should be false and any-hover: hover should be true
  • if a mix of hover-capable and non-hover capable inputs is present, both any-hover: none and any-hover: hover should evaluate to true

Going back to the original scenarios, this would then allow to capture all possible states:

  • at least one of the devices is hover-capable - any-hover:hover will evaluate to true (as before)
  • none of the devices is hover-capable - any-hover:hover will evaluate to false, any-hover:none evaluates to true (as before)
  • at least one, but /not/ all, device is non-hover-capable - any-hover:hover will evaluate to true, any-hover:none will also evaluate to true; this is a new capability that couldn't be tested before
  • /all/ devices are hover-capable - any-hover:hover will evaluate to true, any-hover:none will evaluate to false; this is also a new capability that couldn't be tested before (with the change to none, this now actually gives you confidence in the any-hover:none to mean "none of the pointing devices is non-hover-capable)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions