Skip to content

fix: respect aria-disabled in hover and active styles - #11055

Open
tujoworker wants to merge 2 commits into
fix/hover-mixin-touch-keyboardfrom
fix/interaction-mixins-aria-disabled
Open

tujoworker wants to merge 2 commits into
fix/hover-mixin-touch-keyboardfrom
fix/interaction-mixins-aria-disabled

Conversation

@tujoworker

@tujoworker tujoworker commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

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 native disabled attribute.

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.

@tujoworker
tujoworker force-pushed the fix/interaction-mixins-aria-disabled branch from 6acfa67 to 675d446 Compare November 24, 2026 13:22
@tujoworker
tujoworker changed the base branch from main to fix/hover-mixin-touch-keyboard November 24, 2026 13:23
langz

This comment was marked as outdated.

langz

This comment was marked as outdated.

langz

This comment was marked as outdated.

@tujoworker
tujoworker added this pull request to stack #11061 November 24, 2026 16:35
langz

This comment was marked as outdated.

@langz langz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 only Table.screenshot.test.ts and 6 PNGs, so the mixins in utilities.scss are unchanged since 737f250.
  • Still resolved: the e2e "Both disabled" row and its cursor assertions. CI's Run e2e tests passes on this head.
  • Still open (optional): the three removed Button.test.tsx assertions. Button.test.tsx did not change, so the suggestion below still applies.
  • Not re-raised: the optional Tabs, Chip, Card.Action and Anchor follow-ups from my third review.

Suggestions (non-blocking)

  1. The keyboard focus test still simulates hover. Table.screenshot.test.ts:27 passes ['hover', 'focus'] for keyboard 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.
  2. Update the three removed Button assertions instead of deleting them. This still holds from my last review. Button.test.tsx loses the only checks that Button's own hover and pressed rules skip aria-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 :active and for the tertiary .dnb-button__text rule.

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__trigger in [data-visual-test="table-in-card"]), style: { width: '40rem' } and wrapperStyle as the old test.
    • The hover test simulates only hover. That is CSS emulation (emulatePseudoStateViaCSS), without a key press. data-whatintent stays initial, 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.
  • New baselines, compared with the old combined baseline from main.
    • On hover: the background is rgb(216, 243, 236) in light mode and rgb(2, 57, 57) in dark mode, the same as main. 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) or rgb(28, 28, 30). The 3px focus ring is rgb(39, 106, 206), as on main, 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.
  • 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 in main's dark baseline.
  • Firefox reproduction on the previews. I repeated the test's steps on this head (00dcd0d9), #11053 (31b28adf) and main (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, main has changed nothing in Table, Button, the core styles or the screenshot engine, and yarn.lock is the same.
    • With #11053's current head: 29f8a22 is already the parent of this PR, so there is nothing to merge.
  • CI on this head. Run visual-regression tests passes: 3,208 of 3,208 screenshots, 2 more than on 737f250. 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.

Card menu button, Firefox baselines zoomed 3x: before (main) one combined image with hover background and focus ring; after (this PR) one hover image and one keyboard focus image, in light and dark mode


CI on b18336ea58: all 23 checks passed. Rechecked just before posting: the head is still b18336e.

This branch was successfully deployed

2 active deployments
Package preview — b18336ea Deployed Nov 24, 2026 by github-actions[bot]
Portal preview — b18336ea Deployed Nov 24, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants