Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(CodeSnippet): ariaLabel to aria-label
Browse files Browse the repository at this point in the history
jsehull committed Mar 1, 2023
1 parent f5b9a13 commit 9107313
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
@@ -529,16 +529,17 @@ Map {
},
"CodeSnippet" => Object {
"defaultProps": Object {
"ariaLabel": "Copy to clipboard",
"aria-label": "Copy to clipboard",
"showLessText": "Show less",
"showMoreText": "Show more",
"type": "single",
"wrapText": false,
},
"propTypes": Object {
"ariaLabel": Object {
"aria-label": Object {
"type": "string",
},
"ariaLabel": [Function],
"children": Object {
"type": "node",
},
21 changes: 16 additions & 5 deletions packages/react/src/components/CodeSnippet/CodeSnippet.js
Original file line number Diff line number Diff line change
@@ -32,7 +32,8 @@ function CodeSnippet({
feedback,
feedbackTimeout,
onClick,
ariaLabel,
['aria-label']: ariaLabel,
ariaLabel: deprecatedAriaLabel,
copyText,
copyButtonDescription,
light,
@@ -185,7 +186,7 @@ function CodeSnippet({
<Copy
{...rest}
onClick={handleCopyClick}
aria-label={ariaLabel}
aria-label={deprecatedAriaLabel || ariaLabel}
aria-describedby={uid}
className={codeSnippetClasses}
feedback={feedback}
@@ -229,7 +230,7 @@ function CodeSnippet({
role={type === 'single' ? 'textbox' : null}
tabIndex={type === 'single' && !disabled ? 0 : null}
className={`${prefix}--snippet-container`}
aria-label={ariaLabel || 'code-snippet'}
aria-label={deprecatedAriaLabel || ariaLabel || 'code-snippet'}
onScroll={(type === 'single' && handleScroll) || null}
{...containerStyle}>
<pre
@@ -283,7 +284,17 @@ CodeSnippet.propTypes = {
* Specify a label to be read by screen readers on the containing <textbox>
* node
*/
ariaLabel: PropTypes.string,
['aria-label']: PropTypes.string,

/**
* Deprecated, please use `aria-label` instead.
* Specify a label to be read by screen readers on the containing <textbox>
* node
*/
ariaLabel: deprecate(
PropTypes.string,
'This prop syntax has been deprecated. Please use the new `aria-label`.'
),

/**
* Provide the content of your CodeSnippet as a node or string
@@ -387,7 +398,7 @@ CodeSnippet.propTypes = {
};

CodeSnippet.defaultProps = {
ariaLabel: 'Copy to clipboard',
['aria-label']: 'Copy to clipboard',
type: 'single',
showMoreText: 'Show more',
showLessText: 'Show less',
Original file line number Diff line number Diff line change
@@ -235,6 +235,11 @@ export const Playground = (args) => (
);

Playground.argTypes = {
['aria-label']: {
table: {
disable: true,
},
},
ariaLabel: {
table: {
disable: true,

0 comments on commit 9107313

Please sign in to comment.