Repository navigation
Conversation
Touch browsers keep :hover on the last tapped element, so a tapped action or accordion item kept its green hover outline until something else was tapped. Limit the hover outlines to devices that can hover. The keyboard focus outline excluded hovered items. On touch devices a tapped item 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, also in the fallback for browsers without support for :has().
The focus fallback for browsers without :has() now has rules for devices that can't hover, so a tapped item shows the focus outline too. List them in the test, with their media query.
|
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. Rules that make a tapped element look as at rest now apply exactly when hover styles are off: on devices that cannot hover, and while the tracked input is touch or keyboard. Before, they also applied when no input had been tracked yet, for example without JavaScript, and then cancelled part of the hover style.
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 5fdea53: Changes needed
The List hover outlines now apply only inside @media (any-hover: hover) and while the tracked intent is not touch or keyboard. A tapped item now shows the keyboard focus outline when focus comes back to it. The touch fix works. The restored html:not(…) prefix breaks two mouse states, and two required checks are red. Tested merged with main at ecaa2f5 (clean merge).
Must fix
- The pressed look is gone while the mouse button is down. The prefix adds (0,1,1) to the hover rules at
dnb-list.scss:588-593(action row) and:664-671(accordion header). Onmain, the later:activerules (:614-623,:688-698) had the same specificity and won while the button was down. Now hover wins, so a pressed row keeps the 2px hover outline instead of the 1px pressed outline.
I verified it on the previews ofmain(d85af17f) and this head (8e8c408d). I pressed the mouse on each of the first 12 action rows and accordion headers of the List demos. Onmain, 0 of 12 kept the hover outline while pressed (1px rgb(20, 85, 90)). On this head, 12 of 12 did in Chromium (2px rgb(0, 114, 114)), and 6 of 6 in Firefox. Control: when I remove only the prefix from the loaded CSS of the head preview, 0 of 12 do. This is the same cause W06b reported for Chip and MultiSelection today. - The hover outline of a nested row loses its outer pixel, and
Run e2e testsfails. The hover mixin setsz-index: 2on the row. Onmainthat rule lost to… > .dnb-list__item__accordion__content .dnb-list__item:is(:hover, :has(> :focus-visible)) { z-index: 11 }(:743-748), which is (0,4,0). With the prefix, the hover rule is (0,4,1) and wins. So a hovered nested row stays atz-index: 2, and its neighbours cover the outer pixel of its outline on the sides and the bottom.
CI failsList.e2e.spec.ts:389("paints the full nested side and bottom hover and focus outline") in Firefox at 400px and 1024px. I ran that test against the previews: 2 of 2 passed onmain, and 2 of 2 failed on this head. With my own copy of its steps, both action rows reportrowZ=2and gray edge pixels (235,235,235) on this head in Firefox and Chromium. Onmainthey reportrowZ=11and green edge pixels. With the prefix removed from the loaded CSS, the head passes again. Focus states and the accordion header pass in all runs. ListStyles.test.tsfails, andRun testsis red. "should show the outline of a focused item in browsers without :has()" still expects the six fallback rules inside@media (hover: none), without a prefix (ListStyles.test.ts:56-123). Since30c8a70the CSS has them ashtml:not([data-whatintent=mouse]) …, without that media query. The test file was last changed in6ab7316. It fails the same way in CI and locally on the merge withmain(an assertion error, not a timeout). The expectations need to match the current rules.
A direction for 1 and 2 (not verified by me): keep the old specificity. Either fix the scope plugin so that :where(html…) gets the scope after html (that was the 7dcdcfd approach), or exclude the pressed state and the nested z-index case from the hover rules (for example :hover:not(:active), plus the same prefix on the z-index: 11 rule).
Earlier findings
- Still holds: the earlier review on
6ab7316said that after a tap, Tab and Shift+Tab the item shows the blue focus outline. On this head, the action row shows3px rgb(39, 106, 206), both on a phone and on a touchscreen laptop. Onmainit shows the 2px green hover outline. - Outdated: that review also said that
ListStyles.test.tslists the six(hover: none)fallback rules. The test still does, but the CSS no longer matches it (see must-fix 3).
What I checked
- Phone (Chromium,
isMobile+hasTouch): after a tap on an action row, the outline is the rest outline (1px rgb(235, 235, 235)). Onmainit stays2px rgb(0, 114, 114). - Mouse hover and keyboard focus on action rows and accordion headers: the same as
main, except for the nested z-index case above. Run testsandRun e2e testslogs on5fdea53. The Portal SidebarMenu e2e failure in the same job was flaky (it passed on retry), and it does not touch List.- The tree of
5fdea53is identical tod61f07c. The last commit only undid7dcdcfd. - Not covered: browsers without
:has(), WebKit and real iOS Safari.
CI on 5fdea53740 when I posted this: 21 checks passed; Run e2e tests failure, Run tests failure. Run tests fails in ListStyles.test.ts, because the test still expects the old (hover: none) fallback rules. Run e2e tests fails List.e2e.spec.ts:389 (nested hover outline), a real regression from the raised hover specificity; the Portal SidebarMenu failure in the same job was flaky and passed on retry. Rechecked just before posting: the head is still 5fdea53, 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 List action item or accordion item kept its green hover outline after being tapped, until something else was tapped. It's the same issue as reported for Field.MultiSelection in #11025.
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 hovered items. A tapped item 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 item too. This also covers the fallback for browsers without:has(), and the stacking of focused rows inside an open accordion.Use together with #11053 for the shared hover behavior.
Before / after