Keyboard Accessibility Fix: "Skip to content" link for documentation pages. (#480)

* As part of accessibility requirements, Users who rely on keyboard for navigation should have a way to bypass repetitive content while navigating with Tab key.
The concept of 'Skip to main content' link is to click it to go directly to main content, instead of traversing across the entire side-bar, headers, table of contents etc.

* Linting
This commit is contained in:
Manish Kumar Gupta 2024-10-15 09:47:37 -07:00 коммит произвёл GitHub
Родитель 61d5ee8ce0
Коммит c77cfff7fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 26 добавлений и 1 удалений

Просмотреть файл

@ -35,6 +35,18 @@ export const logoImageStyle = mergeStyles({
lineHeight: "1", lineHeight: "1",
}); });
export const skipContentStyle = mergeStyles({
left: "50%",
position: "absolute",
transform: "translateY(-250%)",
padding: "8px",
transition: "transform 0.3s",
"&:focus": {
transform: "translateY(0%)",
},
});
export const headerPipeStyle = mergeStyles({ export const headerPipeStyle = mergeStyles({
marginTop: "0px !important", marginTop: "0px !important",
marginLeft: "7px !important", marginLeft: "7px !important",

Просмотреть файл

@ -9,6 +9,7 @@ import DocsHtmlContent from "./components/DocsHtmlContent";
import Topic from "./components/Topic"; import Topic from "./components/Topic";
import { DATA_URL, SAS_URL, STAC_URL } from "../../utils/constants"; import { DATA_URL, SAS_URL, STAC_URL } from "../../utils/constants";
import ScrollToTop from "../../components/ScrollToTop"; import ScrollToTop from "../../components/ScrollToTop";
import { skipContentStyle } from "components/Header/styles";
const OpenApiSpec = React.lazy(() => import("./components/OpenApiSpec")); const OpenApiSpec = React.lazy(() => import("./components/OpenApiSpec"));
@ -59,6 +60,15 @@ const Docs = () => {
const documentationPane = ( const documentationPane = (
<div className="grid-content" style={docPageStyle}> <div className="grid-content" style={docPageStyle}>
<Link
className={skipContentStyle}
onClick={() => {
const urlWithoutHash = window.location.href.split("#")[0];
window.location.href = urlWithoutHash + "#generated-docs-content";
}}
>
Skip to content
</Link>
{tocComponent} {tocComponent}
<div style={docContentStyle}> <div style={docContentStyle}>
{breadcrumb} {breadcrumb}

Просмотреть файл

@ -9,12 +9,14 @@ import { a11yPostProcessDom } from "../../../utils";
interface DocsHtmlContentProps { interface DocsHtmlContentProps {
className: string; className: string;
markupJson: any; markupJson: any;
idText?: string;
} }
const DocsHtmlContent: React.FC<DocsHtmlContentProps> = ({ const DocsHtmlContent: React.FC<DocsHtmlContentProps> = ({
className, className,
markupJson, markupJson,
children, children,
idText,
}) => { }) => {
const navigate = useNavigate(); const navigate = useNavigate();
const contentRef = useRef<HTMLDivElement>(null); const contentRef = useRef<HTMLDivElement>(null);
@ -114,7 +116,7 @@ const DocsHtmlContent: React.FC<DocsHtmlContentProps> = ({
: DOMPurify.sanitize(bodyWithRoutedLinks); : DOMPurify.sanitize(bodyWithRoutedLinks);
const content = processedMarkup ? ( const content = processedMarkup ? (
<div className={className}> <div className={className} id={idText}>
{children} {children}
<div <div
ref={contentRef} ref={contentRef}

Просмотреть файл

@ -27,6 +27,7 @@ const Topic: React.FC<TopicProps> = ({ topics }) => {
<> <>
<div style={bodyStyle}> <div style={bodyStyle}>
<DocsHtmlContent <DocsHtmlContent
idText="generated-docs-content"
className="generated-docs markdown-source" className="generated-docs markdown-source"
markupJson={doc} markupJson={doc}
/> />