From 5042f379e968e3f30d93292f1d0cd19c91f75df2 Mon Sep 17 00:00:00 2001 From: PelayoFelgueroso Date: Mon, 2 Feb 2026 13:58:59 +0100 Subject: [PATCH] Fix issues in Tabs component --- packages/lib/src/tabs/Tabs.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/lib/src/tabs/Tabs.tsx b/packages/lib/src/tabs/Tabs.tsx index ddf60c375..16b72b074 100644 --- a/packages/lib/src/tabs/Tabs.tsx +++ b/packages/lib/src/tabs/Tabs.tsx @@ -96,7 +96,7 @@ const DxcTabs = ({ children, iconPosition = "left", margin, tabIndex = 0 }: Tabs (child) => (child.props.active || child.props.defaultActive) && !child.props.disabled ); const initialTab = activeChild ?? childrenArray.find((child) => !child.props.disabled); - return initialTab?.props.label ?? initialTab?.props.tabId ?? ""; + return initialTab?.props.tabId ?? initialTab?.props.label ?? ""; }); const [innerFocusIndex, setInnerFocusIndex] = useState(null); const [scrollLeftEnabled, setScrollLeftEnabled] = useState(false); @@ -110,7 +110,7 @@ const DxcTabs = ({ children, iconPosition = "left", margin, tabIndex = 0 }: Tabs const focusedChild = innerFocusIndex != null ? childrenArray[innerFocusIndex] : null; return { activeTabId: activeTabId, - focusedTabId: isValidElement(focusedChild) ? (focusedChild.props.label ?? focusedChild.props.tabId) : "", + focusedTabId: isValidElement(focusedChild) ? (focusedChild.props.tabId ?? focusedChild.props.label) : "", iconPosition, isControlled: childrenArray.some((child) => typeof child.props.active !== "undefined"), setActiveTabId: setActiveTabId, @@ -146,7 +146,7 @@ const DxcTabs = ({ children, iconPosition = "left", margin, tabIndex = 0 }: Tabs }; const handleOnKeyDown = (event: KeyboardEvent) => { - const activeTab = childrenArray.findIndex((child) => (child.props.label ?? child.props.tabId) === activeTabId); + const activeTab = childrenArray.findIndex((child) => (child.props.tabId ?? child.props.label) === activeTabId); let index; switch (event.key) { case "Left": @@ -231,7 +231,7 @@ const DxcTabs = ({ children, iconPosition = "left", margin, tabIndex = 0 }: Tabs {Children.map(children, (child) => - isTabElement(child) && child.props.tabId === activeTabId ? child.props.children : null + isTabElement(child) && (child.props.tabId ?? child.props.label) === activeTabId ? child.props.children : null )} );