Repository navigation
Conversation
Touch browsers keep :hover on the last tapped element. The hover mixin hides the row hover outline after a touch, but not after the user presses a key, and the keyboard focus outline excludes hovered rows. So when the user opened a row with a tap and came back to it with the keyboard, the row showed no focus outline. Limit the row hover styles to devices that can hover. On devices that can't hover, style a tapped row like one without the mouse over it, so it shows the focus outline, and an open row keeps its usual border.
…touch devices Touch browsers keep :hover on the last tapped element. A selectable cell shows its selected border only while it isn't hovered, so a cell that was selected with a tap showed no border until something else was tapped. Its focus outline also excluded hovered cells. On devices that can't hover, show the selected border and the focus outline on a tapped cell, and limit the cell hover outline to devices that can hover. Also hide the underline of the active sort button on a tapped button, as for one without the mouse over it. Put all Table touch tests in TableTouch.e2e.spec.ts.
#11053 limits the hover mixin to devices that can hover. Wrapping the mixin calls here as well gave a doubled media query, and the Table style snapshot went stale without a merge conflict when both changes were merged. Keep the wrappers only on the plain :hover rules.
|
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 e2abbbd: Changes needed
The PR keeps the focus outline, the selected-cell border and the sort button look right after a tap. Those fixes work. But the last commit (e2abbbd, "Restore the html hover check") makes the expanded-row hover rule win over the pressed rule, so an open accordion row no longer shows its pressed background. Tested merged with main at ecaa2f5.
Must fix
-
An expanded accordion row loses its pressed background.
table-accordion.scss:160-166prefixes the expanded-row hover rule withhtml:not([data-whatintent='touch'], [data-whatintent='keyboard']). That raises it from (0,5,0) on main to (0,6,1). The pressed rule attable-accordion.scss:208(…__tr:not(…--disabled):active .dnb-table__td) is (0,5,0). On main it won because it comes later. Now hover wins while the mouse button is down, so the row keeps the white header background instead of the pressedrgb(188, 232, 220). The rule at:214is safe, because it has:not(:active).CI shows the same failure. The visual job fails "Table with accordion … have to match active state on last row" for
ui,sbankenandcoconut(about 10% of pixels differ). The row it presses (#accordion-table-2-3) is an expanded row.Suggested fix: add
:not(:active)to the row in that rule, as:214does. Or move the guard onto the row with zero specificity, as SidebarMenu does on main::hover:not(:where(html[data-whatintent='touch'] *, html[data-whatintent='keyboard'] *)). The scope plugin keeps that working in scoped builds.
How I verified this
I copied three tables from the main preview: a sortable table, an accordion table with one expanded row, and a table with cell buttons. I styled them with CSS compiled from origin/main and from e2abbbd with the UI theme, set data-whatintent="mouse", then hovered and pressed with the real mouse. For the control, I removed only that prefix from the head CSS (3 occurrences), and the pressed background came back.
expanded row, mouse down collapsed row, mouse down
main td-bg=rgb(188, 232, 220) td-bg=rgb(188, 232, 220)
e2abbbd td-bg=rgb(255, 255, 255) td-bg=rgb(188, 232, 220)
e2abbbd, no prefix td-bg=rgb(188, 232, 220) td-bg=rgb(188, 232, 220)
It is the same in Chromium, Firefox and WebKit. The row script adds dnb-table__tr--hover only after a click. Even then, the rule at :160 still matches the pressed row, so both cases are affected.
Suggestions (non-blocking)
- With
keyboardintent, a tapped sort button and a tapped cell still get the hover mixin's underline and 2px border. On main the hover mixin excludes onlytouch. #11053 changes that mixin, as the description says, so merge this together with #11053 or after it.
What I checked
- The touch fixes, with
data-whatintent="touch"and the pointer still over the element, compared with main:- Selected cell: the 1px selected border stays. On main it is
0px. - Active sort button: no underline. On main it is underlined.
- Expanded row: it keeps its resting top border instead of the hover outline.
- I checked these in Chromium. Mouse hover and pressed states of cells, collapsed rows and the sort button match main.
- Selected cell: the 1px selected border stays. On main it is
- Focus after a tap: I focused rows and the selected cell with a real Tab, set keyboard input and intent, and kept the pointer over them. Collapsed rows, expanded rows and the selected cell now show the 3px focus outline. On main they show the 2px hover outline. When the mouse moves onto a focused element (
mouseintent), the result is unchanged from main. I checked this in Chromium and Firefox, and for rows in WebKit. WebKit does not Tab to buttons by default, so it could not test the cell. - Trial merge with
ecaa2f5(a realgit merge --no-commit): no conflicts.Table.test.tsxandTableAccordion.test.tsxpass: 58 tests.stylelinton the 3 SCSS files: clean.
CI on e2abbbd89d when I posted this: 23 checks passed; Run visual-regression tests failure. The visual job fails 3 Table accordion screenshots ('active state on last row' in ui, sbanken and coconut), because hover now wins over the pressed style on an expanded row (must-fix 1). Rechecked just before posting: the head is still e2abbbd, and a real trial merge with main at 541b379 (which now includes #11052) has no conflicts.

A tapped Table row or cell can keep
:hoverwhen the user switches to the keyboard. This can hide its focus outline or selected border and leave the sort button underlined.Use the tracked input for hover and focus styling, so switching between touch, keyboard and mouse also works on devices that have both a mouse and touchscreen. Use together with #11053 for the shared hover behavior.
Before / after