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

Commit

Permalink
[terra-tabs] Fixes tab label update (#1868)
Browse files Browse the repository at this point in the history
Co-authored-by: Sugan G <[email protected]>
  • Loading branch information
sugan2416 and Sugan G authored Nov 2, 2023
1 parent 956ba3e commit 136e9a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/terra-tabs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Fixed
* Fixes issue where tab label fails to get updated due to
having the same key before and after tab label update.

## 7.11.1 - (October 25, 2023)

* Fixed
Expand Down
8 changes: 7 additions & 1 deletion packages/terra-tabs/src/common-tabs/_Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,16 @@ class Tabs extends React.Component {
const prevTab = prevProps.tabData.find((tab) => tab.isSelected === true);
const currTab = this.props.tabData.find((tab) => tab.isSelected === true);
const prevtabKeys = [];
const prevtabLabels = [];
prevProps.tabData.forEach(child => {
prevtabKeys.push(child.id);
prevtabLabels.push(child.label);
});
const curtabKeys = [];
const curtabLabels = [];
this.props.tabData.forEach(child => {
curtabKeys.push(child.id);
curtabLabels.push(child.label);
});

// Allow dynamic addition of tabs.
Expand All @@ -175,8 +179,10 @@ class Tabs extends React.Component {
let isTabEqual = false;
for (let i = 0; i < curtabKeys.length; i += 1) {
const prevKey = prevtabKeys[i];
const prevLabel = prevtabLabels[i];
const curKey = curtabKeys[i];
if (prevKey !== curKey) {
const curLabel = curtabLabels[i];
if (prevKey !== curKey || prevLabel !== curLabel) {
isTabEqual = true;
}
}
Expand Down

0 comments on commit 136e9a9

Please sign in to comment.