Repository navigation
fix: respect aria-disabled in hover and active styles - #11055
tujoworker wants to merge 2 commits into
Conversation
6acfa67 to
675d446
Compare
675d446 to
737f250
Compare
langz
left a comment
There was a problem hiding this comment.
Review of b18336e: Approve
The new commit splits the Table card menu screenshot test into a hover test and a keyboard focus test, with new light and dark baselines. The new hover baselines show the hover background again, and the keyboard focus baselines show the focus ring without it, which is what #11053 intends after a key press. The library code is the same as in 737f250, which I approved earlier, and I found no new defects. Tested merged with main at 541b379: no conflicts.
Earlier findings
- Still resolved: disabled Accordion headers keep
cursor: not-allowed. The new commit changes onlyTable.screenshot.test.tsand 6 PNGs, so the mixins inutilities.scssare unchanged since737f250. - Still resolved: the e2e "Both disabled" row and its
cursorassertions. CI'sRun e2e testspasses on this head. - Still open (optional): the three removed
Button.test.tsxassertions.Button.test.tsxdid not change, so the suggestion below still applies. - Not re-raised: the optional Tabs, Chip,
Card.Actionand Anchor follow-ups from my third review.
Suggestions (non-blocking)
- The keyboard focus test still simulates hover.
Table.screenshot.test.ts:27passes['hover', 'focus']forkeyboard focus, so the test hovers first and then presses Tab. On this head, the extra hover step changes no pixels, because #11053 turns hover styles off after a key press. So the test checks something its name does not say: that hover stays off while the button has keyboard focus. If that check is intended, a name like "on keyboard focus while hovered" would make a future failure easier to understand. If not,simulate: 'focus'renders the same image. - Update the three removed Button assertions instead of deleting them. This still holds from my last review.
Button.test.tsxloses the only checks that Button's own hover and pressed rules skiparia-disabled="true", a contract from #10278. The regexes need the guard at its new position, for example\.dnb-button--primary:hover:not\(\[disabled\]\):where\(:not\(${ariaDisabled}\)\)[^{]*\{\s*--button-color-bg: var\(--button-color-bg--hover\);. The same pattern works for:activeand for the tertiary.dnb-button__textrule.
Stack note
This commit does not fix #11053's own Run visual-regression tests job. #11053's head 29f8a22 still has the combined test and its old baselines, which the test cannot match after #11053's change. That job stays red until #11053 gets this commit, or the same split. If #11053 is merged first without it, main gets the same 2 failures.
What I checked
- Test change.
- Each new test uses the same
selector,simulateSelector(.dnb-popover__triggerin[data-visual-test="table-in-card"]),style: { width: '40rem' }andwrapperStyleas the old test. - The hover test simulates only
hover. That is CSS emulation (emulatePseudoStateViaCSS), without a key press.data-whatintentstaysinitial, so #11053's hover selector still matches. - The old test name and both of its PNGs are gone. No file in the repository refers to the old name. The 4 new PNG names match the 4 test names, and every Table in Card test has exactly one PNG.
- Each new test uses the same
- New baselines, compared with the old combined baseline from
main.- On hover: the background is
rgb(216, 243, 236)in light mode andrgb(2, 57, 57)in dark mode, the same asmain. The 2px hover ring is visible, and the blue focus ring is not. Each differs from the old baseline by 497 px, all inside the button area. - On keyboard focus: the background is the card's own color,
rgb(255, 255, 255)orrgb(28, 28, 30). The 3px focus ring isrgb(39, 106, 206), as onmain, and the button keeps its 1px resting border. Each differs from the old baseline by 1,051 px in light mode and 1,052 px in dark mode, again only inside the button area.
- On hover: the background is
- Dark mode. Both dark baselines are dark. The card is
rgb(28, 28, 30), the text is light, and the button colors are the dark-mode tokens. Only the 16px frame outside the card is white, the same as inmain's dark baseline. - Firefox reproduction on the previews. I repeated the test's steps on this head (
00dcd0d9), #11053 (31b28adf) andmain(cc21ba1a), in light and dark mode. I checked that the DNB fonts had loaded.- The button colors in my captures match the committed baselines in all 4 cases.
- On this head and on #11053, "hover and focus" and "focus only" render identical images: 0 px differ, in light and dark. On
main, the same pair differs by 1,042 px (light) and 1,041 px (dark), the hover background, so the comparison can detect the difference. - Hover alone renders the same on this head, #11053 and
main(0 px differ, light and dark). - My captures do not match the baselines pixel for pixel. Text anti-aliasing differs between my Mac and CI, so I compared colors at fixed points of the button.
- Real regressions. I found none behind the split. Hover still shows with the mouse, and focus still shows with the keyboard. Hover now stays off while the button has keyboard focus. That is #11053's intended behavior.
- Merges.
- With
main(541b379): no conflicts. Since the PR's base,mainhas changed nothing in Table, Button, the core styles or the screenshot engine, andyarn.lockis the same. - With #11053's current head:
29f8a22is already the parent of this PR, so there is nothing to merge.
- With
- CI on this head.
Run visual-regression testspasses: 3,208 of 3,208 screenshots, 2 more than on737f250. Its log lists all 4 new Table in Card tests as passed. Lint, type checks, unit, build and e2e tests also pass. I also ran Prettier on the test file myself.
CI on b18336ea58: all 23 checks passed. Rechecked just before posting: the head is still b18336e.

Controls marked with
aria-disabled="true"can still receive keyboard focus, but should not look interactive when hovered or pressed. Button already handles this itself; the shared hover and active mixins only check the nativedisabledattribute.Move Button's ARIA check into the shared mixins so their users get the same behavior. Keep keyboard focus styles available for ARIA-disabled controls.
This builds on #11053. Merge that PR first.