Repository navigation
Conversation
Touch browsers keep :hover on the last tapped element, so a tapped Radio kept its hover colors and looked different from other checked radios until something else was tapped. Limit the hover styles to devices that can hover. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The hover rule was more specific than the pressed rule, so a pressed Radio kept its hover colors. Exclude :active from the hover rules, as Checkbox and Switch do, so the pressed styles apply. 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 8845e48: Approve (posted as a comment, because GitHub does not let the PR author approve their own PR)
Since fcc5dac, the branch took over the #11009 changes (any-hover and the intent check). Its own change on top of #11009 is still only :not(:active) on the two hover rules plus the six pressed screenshots. I found no defects. Tested merged with main at 541b379: the merge is clean.
Suggestions (non-blocking)
- The same touchscreen-laptop limitation as #11009. After a mouse click on a form field, a tap does not update
data-whatintent(whatInput.ts), so the tapped Radio can keep its hover look. It is not a regression, and the fix belongs inwhatInput.ts.
What I checked
- Delta:
8845e48reverts32cc364, so the tree equalsfcc20da.git diff 578330b 8845e48(the current #11009 head) changes only the two hover selectors, the two style snapshots and the six new screenshots. The screenshots and the screenshot test are unchanged sincefcc5dac. - Stack: I squash-merged #11009 into
mainecaa2f5. A plain merge of this branch on top then conflicts in 3 files (the SCSS and two snapshots), because both branches rewrote the same lines. The PR's own patch applies cleanly there, and the Radio and ToggleButton tests pass 104 of 104. So the rebase after #11009, as the description says, is needed and is simple. - Pressed look with a real held mouse button, all 20 enabled Radios on the demos page, pressing on the control and on the label: Chromium and WebKit show the pressed look in 40 of 40 presses, Firefox in 21 of 21 presses where it sets
:active. Onmain, all of them keep the hover look. Rest and hover looks equalmainin all three browsers (80 of 80 each). Control: when I remove only:not(:active)from the loaded hover rules, Chromium matchesmainagain in 120 of 120 states. - Checked pressed: the dot and ring use
--token-color-background-action-pressedand--token-color-stroke-action-pressed(ui:#14555aon#bce8dc). These tokens resolve in all 6 theme bundles, with eiendom using theuivalues. - Error radios: pressed uses the existing error
--activevalues frommain(dnb-radio.scss:412). These equal the rest look, so the 2 px hover ring drops to the 1 px error border while the button is down. That is what the existing tokens define, not a change in this PR. - Touch emulation in Chromium, every enabled Radio tapped twice: 0 of 40 taps keep the hover look on this head, 40 of 40 on
main, the same as #11009. ToggleButton is unaffected, because its inner radio haspointer-events: none. - Merge with
main541b379, which adds thewhatInput.tschange from #11052: main + #11007 + #11008 + this PR together pass the Switch, Checkbox, Radio, ToggleButton andwhatInputtests, 198 of 198. - CI on this head: the visual job ran 13 impacted screenshot files, including the 6 pressed tests, and they passed.
CI on 8845e48135: all 23 checks passed. Rechecked just before posting: the head is still 8845e48.
A Radio never showed its pressed state. While the mouse button was held down it kept its hover colors, unlike Checkbox and Switch, even though the pressed colors are defined. The hover rule (
:not([disabled]):hover) was more specific than the pressed rule (:active), so hover always won.The hover rules now exclude
:active, like Checkbox and Switch do. New visual tests cover the pressed state of unchecked and checked radios.Builds on #11009, which changes the same rules, so this branch includes that commit. Merge #11009 first. This diff then only contains the pressed state changes.
Use together with #11053 for the shared hover behavior.
Before / after

Hover follows the current input, like Button. A tap hides hover styling, and using the mouse brings it back, including on devices with both a mouse and touchscreen.