Skip to content

Commit defb772

Browse files
feat: add validation
1 parent 7a63e3e commit defb772

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/components/Tabs/TabGroup.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ function TabGroup({
173173
])
174174

175175
useEffect(() => {
176+
if ((children as React.ReactElement)?.props?.hidden) return
177+
console.log('value', value)
178+
console.log('children', children)
176179
handleChangeIndicator(value)
177180
}, [orientation, variant, wideLine, value, children])
178181

src/components/TopPage/TopPage.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) DD360 and its affiliates.
33
*/
44

5-
import React, { useCallback, useMemo } from 'react'
5+
import React, { useCallback } from 'react'
66
import { composeClasses } from 'lib/classes'
77
import Breadcrumbs from 'components/Breadcrumbs'
88
import type { BreadcrumbsProps } from 'components/Breadcrumbs'
@@ -109,12 +109,6 @@ const TopPage = ({
109109
return 'text-blue-600'
110110
}, [actionIcon])
111111

112-
const updateTabs = useMemo(() => {
113-
return tabs?.items.filter((tab) => !tab.hidden)
114-
}, [tabs])
115-
116-
console.log('updateTabs', updateTabs)
117-
118112
return (
119113
<div className={classNameHeader ?? 'sticky top-0 bg-white z-40 px-5'}>
120114
{(optionsBreadcrumbs || lastUpdate) && (
@@ -209,17 +203,19 @@ const TopPage = ({
209203
)}
210204
</Flex>
211205
<div className="-mx-5 mt-1">
212-
{updateTabs ? (
206+
{tabs ? (
213207
<TabGroup value={tabs?.value} onChange={tabs?.setValue}>
214-
{updateTabs?.map((tab, index) => (
215-
<Tab
216-
key={index}
217-
label={tab.label}
218-
disabled={tab.disabled}
219-
hidden={tab.hidden}
220-
toolTipProps={tab.toolTipProps}
221-
/>
222-
))}
208+
{tabs?.items?.map((tab, index) => {
209+
return (
210+
<Tab
211+
key={index}
212+
label={tab.label}
213+
disabled={tab.disabled}
214+
hidden={tab.hidden}
215+
toolTipProps={tab.toolTipProps}
216+
/>
217+
)
218+
})}
223219
</TabGroup>
224220
) : (
225221
<Divider className="mt-3" light />

0 commit comments

Comments
 (0)