From b9a404ed12a743b8f390152f604ae6840361023d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CTamara?= <“tamara@alumni.sabanciuniv.edu”> Date: Fri, 20 Jan 2023 12:33:18 +0300 Subject: [PATCH 1/2] fix(tab):shouldDisplayTabBody prop added --- src/tab/Tab.tsx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/tab/Tab.tsx b/src/tab/Tab.tsx index 7ced92e6..8ae1645e 100644 --- a/src/tab/Tab.tsx +++ b/src/tab/Tab.tsx @@ -19,6 +19,7 @@ interface UncontrolledTabProps { testid?: string; initialActiveTabIndex?: number; customClassName?: string; + shouldDisplayTabBody?: boolean; } // if one of the controlled tab props are present @@ -26,14 +27,14 @@ interface UncontrolledTabProps { // and initialActiveTabIndex should be undefined type ControlledTabProps = | { - activeTabIndex: number; - onTabChange: (index: number) => void; - initialActiveTabIndex?: number; - } + activeTabIndex: number; + onTabChange: (index: number) => void; + initialActiveTabIndex?: number; + } | { - activeTabIndex?: number; - onTabChange?: (index: number) => void; - }; + activeTabIndex?: number; + onTabChange?: (index: number) => void; + }; export type TabProps = ControlledTabProps & UncontrolledTabProps; @@ -41,6 +42,7 @@ function Tab({ testid, items, initialActiveTabIndex = 0, + shouldDisplayTabBody = true, activeTabIndex: activeTabIndexFromProps, children, customClassName, @@ -67,15 +69,17 @@ function Tab({ )} -
- { - children[ + {shouldDisplayTabBody && +
+ { + children[ activeTabIndexFromProps === undefined ? activeTabIndex : activeTabIndexFromProps - ] - } -
+ ] + } +
+ } ); From 8658b09de5d92a4b2a1ba1cdb476f46f78c81266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CTamara?= <“tamara@alumni.sabanciuniv.edu”> Date: Fri, 20 Jan 2023 12:34:10 +0300 Subject: [PATCH 2/2] fix(tab):shouldDisplayTabBody prop added --- src/tab/Tab.tsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/tab/Tab.tsx b/src/tab/Tab.tsx index 8ae1645e..9f805ade 100644 --- a/src/tab/Tab.tsx +++ b/src/tab/Tab.tsx @@ -27,14 +27,14 @@ interface UncontrolledTabProps { // and initialActiveTabIndex should be undefined type ControlledTabProps = | { - activeTabIndex: number; - onTabChange: (index: number) => void; - initialActiveTabIndex?: number; - } + activeTabIndex: number; + onTabChange: (index: number) => void; + initialActiveTabIndex?: number; + } | { - activeTabIndex?: number; - onTabChange?: (index: number) => void; - }; + activeTabIndex?: number; + onTabChange?: (index: number) => void; + }; export type TabProps = ControlledTabProps & UncontrolledTabProps; @@ -69,17 +69,17 @@ function Tab({ )} - {shouldDisplayTabBody && + {shouldDisplayTabBody && (
{ children[ - activeTabIndexFromProps === undefined - ? activeTabIndex - : activeTabIndexFromProps + activeTabIndexFromProps === undefined + ? activeTabIndex + : activeTabIndexFromProps ] }
- } + )} );