Repository navigation
Conversation
…devices Touch browsers keep :hover on the last tapped element, so a tapped MultiSelection row kept its hover frame until something else was tapped. Limit the row hover styles to devices that can hover. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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.
The inline hover guard raised the specificity of rules that were a plain :hover on main. Hover then won over pressed, disabled and error styles: a disabled Anchor turned teal on hover, a pressed Card action kept its hover outline, and a Textarea with an error lost its red border on hover. Wrap the guard in :where() so each rule keeps the specificity it has on main.
The :where() wrapper put the html element after the style scope class in scoped builds (.eufemia-scope--portal :where(html...)), so these hover rules never matched there. Restore the previous check until the specificity fix also works with style scoping.
langz
left a comment
There was a problem hiding this comment.
Review of 65fc529: Changes needed
Since the last review (952f8c1), the row hover rule moved from @media (hover: hover) to @media (any-hover: hover) with an html:not([data-whatintent='touch'], [data-whatintent='keyboard']) check, the touch e2e tests were removed, and the touch focus rule now checks the intent instead of (hover: none). 65fc529 reverts the :where() wrapper from a5fe28a, so the tree equals cf5be28. The touch fix works, but the check raises the specificity of the hover rule, and the pressed frame no longer shows. Tested merged with main at ecaa2f5.
Must fix
- Hover now wins over the pressed state, so a row never shows its pressed frame with a mouse. On
main,&:hover:not(&--disabled)and&:active:not(&--disabled)(dnb-multi-selection.scss:160and:169) have the same specificity, and the later:activerule wins. Thehtml:not(...)prefix adds 0,1,1 to the hover rule, so it now wins while the mouse button is down.
I pressed each of the 27 enabled demo rows with a real mouse (hover, mouse button down, release outside the row), on themainpreview and onhttps://pr-11025.eufemia-e25.pages.dev, which serves this tree (its CSS has thehtml:not(...)check without:where()). Hover looks the same on 27 of 27 rows. Pressed: onmainthe row frame is 1pxrgb(20, 85, 90)(pressed). On this PR it stays 2pxrgb(0, 114, 114)(hover), on 27 of 27 rows in Chromium and in WebKit. In Firefox,mainshows a pressed frame on only 1 row, and that row differs too. Control: when I remove only thehtml:not(...)prefix from the loaded CSS on the PR preview, the pressed frame equalsmainon 27 of 27 rows.
CI confirms it:Run visual-regression testson65fc529failsMultiSelection > should match active state of item.
Suggested fix: keep the check, but at zero specificity and inside the compound selector, so the style scope plugin leaves it alone. For example&:hover:not(&--disabled):where(html:not([data-whatintent='touch'], [data-whatintent='keyboard']) *). I checked this form on #11010: it survives the scope plugin, it matches only with the intentmouseor with no intent, and a later:activerule still wins, in Chromium, Firefox and WebKit.
Earlier findings
- Resolved: a tapped row had no focus frame when the user returned to it with the keyboard. With touch emulation I tapped row 2, pressed Tab, then Shift+Tab (Alt+Tab in WebKit). The tapped row now shows the 3px
rgb(39, 106, 206)focus frame in Chromium, Firefox and WebKit. Onmainit shows the 2px hover frame instead. The new rulehtml:not([data-whatintent='mouse'])[data-whatinput='keyboard'] &:not(:active):has(...)(dnb-multi-selection.scss:185) does this without(hover: none).
What I checked
- Range-diff
952f8c1..65fc529: five new commits. The net change to the style file is the hover wrapper and the new focus rule.MultiSelection.e2e.spec.tsis back to themainversion. - Real trial merge with
mainecaa2f5(git merge --no-commit): no conflicts,yarn.lockunchanged.MultiSelection.test.tsxpasses 106 of 106. Stylelint and Prettier pass on the style file. - Touch emulation in all three engines: after a tap, the row has no hover frame (1px transparent). On
mainit keeps the 2px hover frame. - Shipped CSS on the PR preview: the hover rule has the check in all 6 theme bundles, and the scope class comes after
html. - CI: the visual job on this head fails exactly one screenshot,
MultiSelection > should match active state of item, which is this must-fix. The other 119 screenshot files pass.
CI on 65fc529cd1 when I posted this: 23 checks passed; Run visual-regression tests failure. Run visual-regression tests fails MultiSelection > should match active state of item: this is must-fix 1. Rechecked just before posting: the head is still 65fc529.

Motivation: https://dnb-it.slack.com/archives/CMXABCHEY/p1795427065802309
On iOS Safari, and in other touch browsers, a Field.MultiSelection row kept its green hover frame after being tapped, until something else was tapped. It's the same issue as reported for Switch in #11007, and the last remaining one in the Forms selection fields.
Hover now follows the current input, using the same
data-whatintenttracking as Button. A tap hides hover styling, it stays hidden when switching to the keyboard, and using the mouse brings it back. This also works on devices with both a touchscreen and a mouse.@media (hover: hover)only describes the primary pointer's capabilities. It can stay true while the touchscreen is being used, so it does not provide the same switching.A tapped row still matches
:hoveron touch devices, so the keyboard focus frame now also shows on it there.Use together with #11053 for the shared hover behavior.
Before / after