Skip to content

Commit

Permalink
refactor(v2): make code blocks accessible from keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Oct 27, 2020
1 parent d9bfe84 commit 1003e0e
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,9 @@ export default ({
</div>
)}
<div className={styles.codeBlockContent}>
<button
tabIndex={0}
ref={button}
type="button"
aria-label="Copy code to clipboard"
className={clsx(styles.copyButton, {
[styles.copyButtonWithTitle]: codeBlockTitle,
})}
onClick={handleCopyCode}>
{showCopied ? 'Copied' : 'Copy'}
</button>
<div
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
tabIndex={0}
className={clsx(className, styles.codeBlock, {
[styles.codeBlockWithTitle]: codeBlockTitle,
})}>
Expand All @@ -244,6 +235,17 @@ export default ({
})}
</div>
</div>

<button
ref={button}
type="button"
aria-label="Copy code to clipboard"
className={clsx(styles.copyButton, {
[styles.copyButtonWithTitle]: codeBlockTitle,
})}
onClick={handleCopyCode}>
{showCopied ? 'Copied' : 'Copy'}
</button>
</div>
</>
)}
Expand Down

0 comments on commit 1003e0e

Please sign in to comment.