refactor(v2): make code blocks accessible from keyboard (#3649)

This commit is contained in:
Alexey Pyltsyn 2020-10-28 19:51:21 +03:00 committed by GitHub
parent 2aae77124e
commit 9f66545c8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,
})}>
@ -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>
</>
)}