Repository navigation
Conversation
Touch browsers keep :hover on the last tapped element, so a tapped Textarea kept its thick hover border after the user left the field, until something else was tapped. Limit the hover styles to devices that can hover. The focus border is unchanged.
joakbjerk
left a comment
There was a problem hiding this comment.
Looks good. Focus keeps the same border width, and mouse hover is unchanged. Two optional nits inline.
|
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.
Use one focus rule and one hover rule. The hover rule stays after the focus rule, so the hover border color still wins over the focus color.
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 9465eaa: Changes needed
The Textarea hover rule now applies only inside @media (any-hover: hover) and while the tracked intent is not touch or keyboard. The touch fix works. On this head, though, an error Textarea loses its red border on mouse hover. Tested merged with main at ecaa2f5 (clean merge).
Must fix
- An error Textarea turns green on mouse hover. The guard
html:not([data-whatintent='touch'], [data-whatintent='keyboard'])adds (0,1,1) to the hover rule (dnb-textarea.scss:371-378). The hover rule is now (0,6,1). The error rule below it,.dnb-textarea__status--error .dnb-textarea__textarea:not([disabled]):not(.dnb-textarea--disabled) ~ .dnb-textarea__state, is (0,5,0). Onmainboth rules were (0,5,0), so the later error rule kept the red border. Now the hover color wins over the error color. Commit4d7acccfixed exactly this, and9465eaabrought it back when it restored thehtmlcheck. The compiled package CSS has the same order (Textarea.test.tsx.snap:547and:553), so this is not only a portal effect.
I verified it on the previews ofmain(d85af17f) and this head (ae7525ce), in Chromium and Firefox. I used theFormStatusdemo with the mouse over the textarea. Onmainthe border isrgb(213, 37, 37) 0 0 0 2px. On this head it isrgb(0, 114, 114) 0 0 0 2px. It is the same while the field has focus and the mouse is over it. As a control, the default Textarea gives identical results onmainand this head.
Suggested fix: add an error rule inside the same media block, after the hover rule, as Input does for__status--error … :hover. I checked that this rule restores the red 2px border on the head preview:html:not([data-whatintent='touch'], [data-whatintent='keyboard']) &__status--error &__textarea:not([disabled]):not(#{&}--disabled):hover ~ &__state { --textarea-color-border: var(--token-color-stroke-error); }
Earlier findings
- Resolved: both nits from the earlier approval on
ebd4eee. The comment above the focus rule now says// focus, and the repeated focus and hover rules are merged into one each (77d672f). The hover rule still comes after the focus rule. - Still holds: the earlier review said the focus border is unchanged. With focus and the mouse away, the border is
rgb(20, 85, 90) 0 0 0 2pxon bothmainand this head.
What I checked
- Mouse (Chromium, Firefox): the default Textarea shows the same rest, hover, focus + hover and focus colors as
main. The error Textarea differs only under hover (see above). - Phone (Chromium,
isMobile+hasTouch): after a tap and blur, the default and error borders are 1px. Onmainthey keep the 2px hover border. - Touchscreen laptop (desktop Chromium, where
(any-hover: hover)matches, plus CDP touch input): after a tap, blur and Tab, the border is 1px. Moving the mouse brings the 2px hover border back. Onmainit stays 2px after the tap. - Pressed state: Textarea has no
:activerule, so the error rule above is the only one that the higher hover specificity overrides. I compared every rule after the hover rule indnb-textarea.scss. - Unit tests on the merge with
main(ecaa2f5):Textarea.test.tsx, 47 of 47 passed. The style snapshot does not catch the error-hover case, because it only records the selectors. - Not covered: WebKit and real iOS Safari.
CI on 9465eaaa7c: all 23 checks passed. Rechecked just before posting: the head is still 9465eaa, 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 Textarea kept its thick hover border after being tapped, even after the user left the field, until something else was tapped. It's the same issue as reported for Switch in #11007 and for Input in #11039.
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.Use together with #11053 for the shared hover behavior.
Before / after