Skip to content

Commit c019961

Browse files
authored
Fix accessibility issues in docs control (annotate-option, tooltips, navigation) (#56452)
1 parent 70b98d1 commit c019961

File tree

5 files changed

+59
-7
lines changed

5 files changed

+59
-7
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Accessibility fixes for tooltip text spacing and other a11y improvements */
2+
3+
/* Fix tooltip text spacing inheritance - Issue #11442 */
4+
.tooltipped {
5+
&::before,
6+
&::after {
7+
/* Allow tooltips to inherit user's custom text spacing preferences */
8+
letter-spacing: inherit !important;
9+
word-spacing: inherit !important;
10+
line-height: inherit !important;
11+
}
12+
}
13+
14+
/* Enhanced focus indicators for high contrast mode */
15+
@media (prefers-contrast: high) {
16+
.tooltipped {
17+
&:focus-visible::before,
18+
&:focus-visible::after {
19+
outline: 2px solid var(--color-focus-outset);
20+
outline-offset: 2px;
21+
}
22+
}
23+
}

src/content-render/stylesheets/annotate.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@
9090
background: var(--color-segmented-control-button-bg);
9191
border-color: var(--color-segmented-control-button-selected-border);
9292
}
93+
94+
// High contrast theme support
95+
@media (prefers-contrast: high) {
96+
border-color: var(--color-border-default);
97+
98+
&:hover {
99+
background: var(--color-canvas-subtle);
100+
border-color: var(--color-border-emphasis);
101+
}
102+
103+
&.selected {
104+
background: var(--color-accent-emphasis);
105+
color: var(--color-fg-on-emphasis);
106+
border-color: var(--color-border-emphasis);
107+
}
108+
109+
&:focus-visible {
110+
outline: 2px solid var(--color-focus-outset);
111+
outline-offset: 2px;
112+
}
113+
}
93114
}
94115

95116
.annotate-row {

src/content-render/stylesheets/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
@import "syntax-highlighting.scss";
55
@import "alerts.scss";
66
@import "octicon-table-optimization.scss";
7+
@import "accessibility.scss";

src/frame/components/sidebar/SidebarNav.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ export const SidebarNav = ({ variant = 'full' }: Props) => {
3535
className={cx(variant === 'full' ? 'position-sticky d-none border-right d-xxl-block' : '')}
3636
style={{ width: 326, height: 'calc(100vh - 65px)', top: '65px' }}
3737
>
38-
<nav aria-labelledby="allproducts-menu">
38+
<nav
39+
aria-labelledby="allproducts-menu"
40+
role="navigation"
41+
aria-label="Documentation navigation"
42+
>
3943
{variant === 'full' && currentProduct && (
4044
<div className={cx('d-none px-4 pb-3 border-bottom d-xxl-block')}>
4145
<AllProductsLink />
@@ -47,6 +51,7 @@ export const SidebarNav = ({ variant = 'full' }: Props) => {
4751
// Note the `_product-title` is used by the popover preview cards
4852
// when it needs this text for in-page links.
4953
className="d-block pl-1 mb-2 h3 color-fg-default no-underline _product-title"
54+
aria-describedby="allproducts-menu"
5055
>
5156
{currentProductName || currentProduct.name}
5257
</Link>
@@ -61,6 +66,8 @@ export const SidebarNav = ({ variant = 'full' }: Props) => {
6166
'bg-primary overflow-y-auto flex-shrink-0',
6267
)}
6368
style={{ width: 326, height: 'calc(100vh - 175px)', paddingBottom: sidebarPaddingBottom }}
69+
role="region"
70+
aria-label="Page navigation content"
6471
>
6572
<SidebarProduct key={router.asPath} />
6673

src/landings/components/SidebarProduct.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const SidebarProduct = () => {
3333

3434
const productSection = () => (
3535
<div className="ml-3" data-testid="product-sidebar">
36-
<NavList aria-label="Product sidebar">
36+
<NavList aria-label="Product sidebar" role="navigation">
3737
{sidebarTree &&
3838
sidebarTree.childPages.map((childPage) => (
3939
<NavListItem key={childPage.href} childPage={childPage} />
@@ -51,15 +51,15 @@ export const SidebarProduct = () => {
5151
)
5252
return (
5353
<div className="ml-3">
54-
<NavList aria-label="REST sidebar overview articles">
54+
<NavList aria-label="REST sidebar overview articles" role="navigation">
5555
{conceptualPages.map((childPage) => (
5656
<NavListItem key={childPage.href} childPage={childPage} />
5757
))}
5858
</NavList>
5959

6060
<hr data-testid="rest-sidebar-reference" className="m-2" />
6161

62-
<NavList aria-label="REST sidebar reference pages">
62+
<NavList aria-label="REST sidebar reference pages" role="navigation">
6363
{restPages.map((category) => (
6464
<RestNavListItem key={category.href} category={category} />
6565
))}
@@ -90,7 +90,7 @@ function NavListItem({ childPage }: { childPage: ProductTreeNode }) {
9090
>
9191
{childPage.title}
9292
{childPage.childPages.length > 0 && (
93-
<NavList.SubNav aria-label={childPage.title} sx={{ '*': { fontSize: 1 } }}>
93+
<NavList.SubNav aria-label={`${childPage.title} submenu`} sx={{ '*': { fontSize: 1 } }}>
9494
{specialCategory && (
9595
<NavList.Item href={childPage.href} as={Link} aria-current={isActive ? 'page' : false}>
9696
{childPage.title}
@@ -155,7 +155,7 @@ function RestNavListItem({ category }: { category: ProductTreeNode }) {
155155
>
156156
{category.title}
157157
{category.childPages.length > 0 && (
158-
<NavList.SubNav aria-label={category.title} sx={{ '*': { fontSize: 1 } }}>
158+
<NavList.SubNav aria-label={`${category.title} submenu`} sx={{ '*': { fontSize: 1 } }}>
159159
{category.childPages.map((childPage) => {
160160
return (
161161
<NavList.Item
@@ -169,7 +169,7 @@ function RestNavListItem({ category }: { category: ProductTreeNode }) {
169169
{childPage.title}
170170

171171
{routePath === childPage.href && miniTocItems.length > 0 && (
172-
<NavList.SubNav aria-label={childPage.title}>
172+
<NavList.SubNav aria-label={`${childPage.title} table of contents`}>
173173
{miniTocItems.map((item) => {
174174
const isAnchorCurrent = visibleAnchor === item.contents.href
175175
return (

0 commit comments

Comments
 (0)