Skip to content

Commit b4dfcdd

Browse files
committed
fix: Reveal hover-only controls on keyboard focus
The section anchors, the code-block copy button and the nav menu toggle are all `visibility: hidden` until their container is hovered, so a keyboard user tabs onto a control that is not drawn and cannot see where focus is. Pairing each reveal with focus is what makes the focus rings on those three reachable without a mouse.
1 parent 6eeb459 commit b4dfcdd

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

ui/src/css/doc.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,20 @@
132132
content: "\00a7";
133133
}
134134

135+
/* A focusable control that only appears on hover is invisible to anyone
136+
* tabbing to it, so every reveal below pairs hover with focus. */
135137
.doc h1:hover .anchor,
136138
.doc h2:hover .anchor,
137139
.doc h3:hover .anchor,
138140
.doc h4:hover .anchor,
139141
.doc h5:hover .anchor,
140-
.doc h6:hover .anchor {
142+
.doc h6:hover .anchor,
143+
.doc h1 .anchor:focus-visible,
144+
.doc h2 .anchor:focus-visible,
145+
.doc h3 .anchor:focus-visible,
146+
.doc h4 .anchor:focus-visible,
147+
.doc h5 .anchor:focus-visible,
148+
.doc h6 .anchor:focus-visible {
141149
visibility: visible;
142150
}
143151

@@ -841,7 +849,8 @@
841849
z-index: 1;
842850
}
843851

844-
.doc .listingblock:hover .source-toolbox {
852+
.doc .listingblock:hover .source-toolbox,
853+
.doc .listingblock:focus-within .source-toolbox {
845854
visibility: visible;
846855
}
847856

ui/src/css/nav.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
background-image: url(../img/octicons-16.svg#view-fold);
134134
}
135135

136-
.nav-panel-menu.is-active:hover .nav-menu-toggle {
136+
.nav-panel-menu.is-active:hover .nav-menu-toggle,
137+
.nav-panel-menu.is-active:focus-within .nav-menu-toggle {
137138
visibility: visible;
138139
}
139140

0 commit comments

Comments
 (0)