Skip to content

Commit

Permalink
fix(CodeSnippet): a11y tabstop + attributes (#13310)
Browse files Browse the repository at this point in the history
* fix(CodeSnippet): a11y tabstop + attributes

* fix(CSS): add Carbon CSS to focus outline

* refactor(CodeSnippet): relocate parens
  • Loading branch information
jsehull authored Mar 9, 2023
1 parent 0229bf0 commit 2d94846
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/react/src/components/CodeSnippet/CodeSnippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,14 @@ function CodeSnippet({
<div {...rest} className={codeSnippetClasses}>
<div
ref={codeContainerRef}
role={type === 'single' ? 'textbox' : null}
tabIndex={type === 'single' && !disabled ? 0 : null}
role={type === 'single' || type === 'multi' ? 'textbox' : null}
tabIndex={
(type === 'single' || type === 'multi') && !disabled ? 0 : null
}
className={`${prefix}--snippet-container`}
aria-label={ariaLabel || 'code-snippet'}
aria-readonly={type === 'single' || type === 'multi' ? true : null}
aria-multiline={type === 'multi' ? true : null}
onScroll={(type === 'single' && handleScroll) || null}
{...containerStyle}>
<pre
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ $copy-btn-feedback: $background-inverse !default;
order: 1;
overflow-y: auto;
transition: max-height $duration-moderate-01 motion(standard, productive);

&:focus {
@include focus-outline('outline');

outline-offset: 0;
}
}

// expanded snippet container
Expand Down

0 comments on commit 2d94846

Please sign in to comment.