Repository navigation
Conversation
Touch browsers keep :hover on the last tapped element. The hover mixin hides the hover style after a touch, but not after the user presses a key. So when the user tapped a header and came back to it with the keyboard, the header showed the hover border instead of the focus outline, because the focus outline excludes hovered headers. Limit the hover styles to devices that can hover, and show the focus outline on a hovered header on devices that can't hover.
Prettier wrapped a custom property value differently after the snapshot was written, and Sass keeps those line breaks in the CSS. Firefox does not show focus-visible on a focus() call after a tap, so move focus with Tab and Shift+Tab, as a keyboard user does.
#11053 limits the hover mixin to devices that can hover. Wrapping the mixin call here as well gave a doubled media query and a stale style snapshot when both changes were merged. Keep only the focus outline fix here, and check only the focus outline in the touch test.
|
Why This is the industry standard: Tailwind CSS v4 applies its The |
langz
left a comment
There was a problem hiding this comment.
Review of 03cf051: Approve (posted as a comment, because GitHub does not let the PR author approve their own PR)
A header that was tapped and then reached with the keyboard now shows the focus outline. Desktop keyboard focus is unchanged, and so is a focused header that the mouse hovers with mouse intent. Tested merged with main at ecaa2f5.
Earlier findings
- Resolved: the doubled
@mediawrapper and the stale snapshot when merged with #11053.f4327d2leaves hover to the mixin. The snapshot now differs from main only by the new focus rule.
Suggestions (non-blocking)
- Without #11053, the tapped-then-Tab header shows the focus outline and the 2px hover border together. The hover mixin still applies with
keyboardintent. The description says to use this with #11053, and that removes the border, so merge #11053 first or together with this. - The e2e tests for the tapped header were removed in
025bd4b, so only the style snapshot covers the new rule now. A unit test cannot do the tap-then-Tab flow, so this is only a note.
What I checked
- I used the outlined and filled headers copied from the main preview, with CSS compiled from
origin/mainand from03cf051. Focus came from a real Tab, so:focus-visiblematched. I then setdata-whatinputanddata-whatintentand moved the real mouse. Chromium, Firefox and WebKit all gave the same result:- Keyboard only: the outline shows on main and on the PR.
- Tap then Tab, with the header still hovered: no outline on main. The PR shows the outline.
- Keyboard focus, then the mouse moved onto the header (
mouseintent): no outline on main or on the PR. Desktop behavior is unchanged. data-whatinput="touch": no outline on main or on the PR.- No input tracked yet, hovered: no outline on main. The PR shows the outline.
- Forced colors (Chromium emulation): the outline stays visible in every focused case. In the tap-then-Tab case it now uses the same color as plain keyboard focus, instead of
CanvasText. - The tertiary variant uses a Button, not
.dnb-accordion__header, so this rule does not reach it. - Scoped builds: the rule starts with
html, so the scope plugin inserts the scope class after it. - Trial merge with
ecaa2f5(a realgit merge --no-commit): no conflicts.Accordion.test.tsxpasses: 66 tests.stylelintondnb-accordion.scss: clean.
CI on 03cf0516b8 when I posted this: 22 checks passed; Run visual-regression tests cancelled. Run visual-regression tests never ran on this head: twice, GitHub did not assign a runner, and the job was cancelled with no steps. The Accordion screenshots are still unchecked, so it needs a re-run before merge. Rechecked just before posting: the head is still 03cf051, and a real trial merge with main at 541b379 (which now includes #11052) has no conflicts.
A tapped Accordion header can keep
:hoverwhen the user switches to the keyboard. That used to hide its focus outline.Use the tracked input to show keyboard focus even while native hover remains. This also covers laptops with both a touchscreen and mouse, where a hover media query can still match during touch use. Use together with #11053 to keep hover styles off after touch followed by a key press.
Before / after