digdir / designsystemet

Designsystemet
https://designsystemet.no
MIT License
68 stars 34 forks source link

Fix sticky hover on touch devices #768

Closed mimarz closed 9 months ago

mimarz commented 10 months ago

We should only show hover states on non-touch devices. Interacting with elements that have a hover-state on touch devices such as mobile or a table leads the hover state "stuck" after interacting with it.

I have previously solved this by wrapping our :hover selector in a designated media query which only enables them when hover is "supported". Look at Switch or Accordion for examples.

@media (hover: hover) and (pointer: fine) { 
/** :hover classes here */ 
}

Actions:

Notes:

mimarz commented 9 months ago

Assigning this to @Magnusrm as its a nice issue to get started with the designsystem @framitdavid :)