Repository navigation
Conversation
…press The hover mixin hides hover styles while data-whatintent is "touch". Touch browsers keep :hover on the last tapped element, and whatInput sets data-whatintent to "keyboard" as soon as the user presses a key. So a tapped Button, Tag, ToggleButton, Tab or DrawerList option showed its hover style again when the user typed or pressed Tab on a touch device with a keyboard. Also limit the hover mixin and the Tabs tab-hover mixin to devices that can hover. Devices that can hover keep the JS check, so touchscreen laptops work as before. The Tabs focus outline excludes hovered tabs. On devices that can't hover, show it on a tapped tab too.
#11053 limits the hover mixin to devices that can hover. Wrapping the mixin call here as well gave a doubled media query and a stale style snapshot when both changes were merged. Keep only the focus outline fix here, and check only the focus outline in the touch test.
#11053 limits the hover mixin to devices that can hover. Wrapping the mixin calls here as well gave a doubled media query, and the Table style snapshot went stale without a merge conflict when both changes were merged. Keep the wrappers only on the plain :hover rules.
|
Why This is the industry standard: Tailwind CSS v4 applies its The |
Wrap the hover guard in @media (any-hover: hover) and check that the current input is not touch or keyboard, instead of requiring mouse intent. Hover styles now work before Eufemia's input tracking has started and without it, while a tap or a key press still turns them off. any-hover keeps hover for a trackpad on iPad and a mouse on Android tablets, where hover: hover is false. The selector specificity is unchanged.
langz
left a comment
There was a problem hiding this comment.
Review of 29f8a22: no critical findings.
- New in this round:
utilities.hover()now puts the hover rule inside@media (any-hover: hover)and checkshtml:not([data-whatintent='touch'], [data-whatintent='keyboard'])instead ofhtml[data-whatintent='mouse']. The specificity is the same (0,1,1). - Touch emulation on the branch preview (https://31b28adf.eufemia-e25.pages.dev): after a tap and a key press, Button and Tabs look the same as on the previous head (
d02b778): focus outline, no hover look. - Mouse hover in desktop Chromium equals
main, also with JavaScript turned off. The previous head needed JavaScript for any hover (measured on Button and Input). - The 24 changed style snapshots only add the wrapper (81 times) and the new check. Merges cleanly with
main. CI: 13 of 21 checks are done and none failed; the rest is still running.
langz
left a comment
There was a problem hiding this comment.
Follow-up on 29f8a22: one required check fails
This adds one finding to the review from 15:19 on the same head. At that time the visual job was still running. It has now finished, and it fails.
Must fix
Run visual-regression testsfails 2 screenshots: "Table in Card in light mode > shows the card menu hover and keyboard focus", and the same test in dark mode. The other 119 screenshot files pass. The test (Table.screenshot.test.ts:18) simulateshoverand thenfocuson the card menu button ([data-visual-test="table-in-card"] .dnb-popover__trigger). The focus step uses a key press, which setsdata-whatintent="keyboard". With this PR, a key press turns hover styles off, so the button loses its hover background while it keeps the focus ring.- I repeated the test's steps in Firefox on the
mainpreview and on this PR's preview.mainshows the hover background (rgb(216, 243, 236)). This PR showsrgb(255, 255, 255). - #11055 (stacked on this PR) fails the same 2 screenshots. Its render is pixel-identical to this PR's (0 px differ), so the cause is here, not in #11055.
- This is the behavior the PR intends. So the fix is in the test, not in the CSS: update the 2 baselines, or split the test into a hover screenshot and a keyboard focus screenshot. Splitting keeps a baseline for the hover background.
- I repeated the test's steps in Firefox on the
What I checked
- The CI log of
Run visual-regression testson29f8a22(job 138622558333): 1 of 120 files fails, with these 2 tests after 5 retries each. - The same steps in Firefox on the
mainpreview, this PR's preview and #11055's head (light mode). I did not render the dark variant locally. - The trigger has no
aria-disabled, so #11055's guard cannot cause it.
CI on 29f8a22494 when I posted this: 23 checks passed; Run visual-regression tests failure. Run visual-regression tests fails the 2 Table in Card screenshots in must-fix 1. Rechecked just before posting: the head is still 29f8a22.

Touch browsers can keep
:hoveron a tapped control. A key press then changes the tracked input from touch to keyboard, which used to bring hover styles back. On a laptop with both a mouse and touchscreen,@media (hover: hover)can still match during touch use because it describes the primary pointer's capability.Show hover styles only on devices with a pointer that can hover (
@media (any-hover: hover)), and not while the tracked input is touch or keyboard. This follows switches between touch, keyboard and mouse on the same device, and keeps the Tabs keyboard outline visible after a tap. Without Eufemia's input tracking, the media query alone decides.The browser may update hover media queries when its primary pointer changes, but that does not guarantee tracking each input switch. See the CSS media query definition.
Before / after