Repository navigation
Conversation
Touch browsers keep :hover on the last tapped element, so a tapped Card.Action kept its green hover outline until something else was tapped. Limit the hover outline to devices that can hover. The keyboard focus outline excluded a hovered card. On touch devices a tapped card keeps :hover, so it showed the hover outline instead of the focus outline when the user returned to it with the keyboard. Show the focus outline there too.
Firefox does not show focus-visible on a focus() call after a tap, so the test failed there although the focus outline works with the keyboard. Move focus with Tab and Shift+Tab, as a keyboard user does.
|
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 6e2fc0c: Changes needed
The Card.Action hover outline now applies only inside @media (any-hover: hover) and while the tracked intent is not touch or keyboard. A tapped card now shows the focus outline when focus comes back to it. The touch fix works. The restored html:not(…) prefix removes the pressed look, and Run visual-regression tests fails on it. Tested merged with main at ecaa2f5 (clean merge, including #10972's Card changes).
Must fix
- A pressed Card.Action keeps the hover outline, and the visual test fails. The prefix adds (0,1,1) to the hover rule (
dnb-card.scss:288-296). It is now (0,4,1). The&:active > .dnb-cardrule below it (:298-302) is still (0,3,0). Onmainthe two had the same specificity, so the later pressed rule won while the mouse button was down. Now hover wins: a pressed card shows the 2px hover outline instead of the 1px pressed outline. Commite696269fixed exactly this, and6e2fc0cbrought it back when it restored thehtmlcheck.
CI fails "Interactive Card for ui > have to match active state" in Firefox after 5 retries (1,628 px differ, 1.262%). I verified it on the previews ofmain(d85af17f) and this head (thepr-11043alias, which serves thehtml:not(…)form of the rule). I pressed the mouse on the 4 Card.Action demos. Onmain, 0 of 4 kept the hover look (--outline-width: .0625rem,#14555a). On this head, 4 of 4 did, in Chromium and in Firefox (.125rem,#007272). Control: when I remove only the prefix from the loaded CSS, 0 of 4 do.
One way to fix it, not verified by me: exclude the pressed state from the hover rule (&:hover:not(:active) > .dnb-card). Another is to keep:where()once the scope plugin puts the scope after:where(html…).
Earlier findings
- Still holds: the earlier review on
7ceec54said that after a tap, Tab and Shift+Tab the card shows the blue 3px focus outline. On this head, it shows--outline-width: .1875remand#276ace, both on a phone and on a touchscreen laptop. Onmainit shows the 2px green hover outline.
What I checked
- Phone (Chromium,
isMobile+hasTouch): after a tap, the card shows the rest outline (.0625rem,#ebebeb). Onmainit keeps the hover outline (.125rem,#007272). - Touchscreen laptop (desktop Chromium, where
(any-hover: hover)matches, plus CDP touch input): the same results as on the phone. - Mouse hover: the same as
mainin Chromium and Firefox. - Unit tests on the merge with
main(ecaa2f5): all Card test files, 113 of 113 passed. - The visual job had one more failure on the first attempt: SidebarMenu for sbanken ("keyboard-focused section option under the mouse pointer"). It passed on retry, and the same failure shows in CI logs of four other PRs today, so it is not this PR. The tree of
6e2fc0cis identical to42e35ab. - Not covered: WebKit and real iOS Safari.
CI on 6e2fc0c5e9 when I posted this: 23 checks passed; Run visual-regression tests failure. Run visual-regression tests fails 'Interactive Card for ui > have to match active state': the restored hover prefix makes the hover outline win over the pressed outline. The SidebarMenu sbanken screenshot in the same job failed once and passed on retry; it is unrelated. Rechecked just before posting: the head is still 6e2fc0c, and a real trial merge with main at 541b379 (which now includes #11052) has no conflicts.

On iOS Safari, and in other touch browsers, a Card.Action kept its green hover outline after being tapped, until something else was tapped. It's the same issue as reported for Switch in #11007 and for List in #11042.
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.The keyboard focus outline excludes a hovered card. A tapped card keeps
:hoveron touch devices, so when the user came back to it with the keyboard (for example on a tablet with a keyboard), it showed the green hover outline instead of the blue focus outline. When the current intent is keyboard, the focus outline now shows on a tapped card too.Use together with #11053 for the shared hover behavior.
Before / after