Skip to content

Commit afb843b

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 7388ad2 commit afb843b

3 files changed

Lines changed: 14 additions & 4 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

@@ -853,7 +861,8 @@
853861
z-index: 1;
854862
}
855863

856-
.doc .listingblock:hover .source-toolbox {
864+
.doc .listingblock:hover .source-toolbox,
865+
.doc .listingblock:focus-within .source-toolbox {
857866
visibility: visible;
858867
}
859868

‎ui/src/css/header.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ body {
193193
color: var(--navbar-menu-font-color-hover);
194194
}
195195

196-
/* font: inherit is required, not tidiness: .svg-icon sizes the magnifier in em,
196+
/* font: inherit is required: .svg-icon sizes the magnifier in em,
197197
* so the UA button font would shrink it from 16px to 13px. */
198198
#search-button {
199199
background: none;

‎ui/src/css/nav.css‎

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

140-
.nav-panel-menu.is-active:hover .nav-menu-toggle {
140+
.nav-panel-menu.is-active:hover .nav-menu-toggle,
141+
.nav-panel-menu.is-active:focus-within .nav-menu-toggle {
141142
visibility: visible;
142143
}
143144

0 commit comments

Comments
 (0)