Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Removed Array from Icon Base (#3717)
Browse files Browse the repository at this point in the history
Co-authored-by: SM051274 <sm051274@cerner.net>
  • Loading branch information
supreethmr and SM051274 authored Feb 6, 2023
1 parent facc56b commit 04cdbc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/terra-icon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Fixed
* Fixed console error `Each child in a list should have a unique "key" prop` thrown due to use of Array.

## 3.51.0 - (January 31, 2023)

* Added
Expand Down
12 changes: 8 additions & 4 deletions packages/terra-icon/src/IconBase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ const IconBase = ({
attributes.className,
);

let svgChildren;
let svgTitleTag;
if (a11yLabel || ariaLabel) {
const svgA11yLabel = React.createElement('title', {}, a11yLabel || ariaLabel);
svgChildren = new Array(svgA11yLabel).concat(children);
svgTitleTag = React.createElement('title', {}, a11yLabel || ariaLabel);
if (ariaLabel) {
// eslint-disable-next-line no-console
console.warn('`ariaLabel` prop has been renamed to `a11yLabel`. please update all the refernces of ariaLabel prop to a11yLabel.'); // to be removed on next major version release.
Expand All @@ -102,7 +101,12 @@ const IconBase = ({
attributes.width = width;
attributes.focusable = focusable;

return <svg {...attributes} className={classes}>{ svgChildren || children }</svg>;
return (
<svg {...attributes} className={classes}>
{svgTitleTag}
{children}
</svg>
);
};

IconBase.propTypes = propTypes;
Expand Down

0 comments on commit 04cdbc1

Please sign in to comment.