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

[Terra-Icon] Removed Array from Icon Base #3717

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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