Skip to content

Commit a84335e

Browse files
Merge pull request #336 from dd3tech/fix/tabs-single-select
Fix: Add validation tab hidden and change validation value single select
2 parents 221f0a3 + 43deb9b commit a84335e

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/components/Form/SingleSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function SingleSelect({
128128
}))
129129

130130
const getInputLabel = () => {
131-
if (!isFilter && !selectedOption) return placeholder || label || ''
131+
if (!isFilter && !selectedOption) return ''
132132
if (!selectedOption) return placeholder || label || ''
133133

134134
return selectedOption.label || selectedOption.value.toString()

src/components/Tabs/TabGroup.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ function TabGroup({
120120
},
121121
[orientation, variant, refContainer, dashRect]
122122
)
123-
124123
const onClick = useCallback(
125124
(event: MouseEvent<HTMLButtonElement>) => {
126125
const nodes = Array.prototype.slice.call(refContainer.current?.children)
@@ -156,6 +155,7 @@ function TabGroup({
156155
...child.props
157156
})
158157
}
158+
if ((child as React.ReactElement)?.props?.hidden) return null
159159
return child
160160
})
161161
}, [
@@ -172,8 +172,9 @@ function TabGroup({
172172
])
173173

174174
useEffect(() => {
175+
if ((children as React.ReactElement)?.props?.hidden) return
175176
handleChangeIndicator(value)
176-
}, [orientation, variant, wideLine, value])
177+
}, [orientation, variant, wideLine, value, children])
177178

178179
return (
179180
<div

src/components/TopPage/TopPage.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,18 @@ const TopPage = ({
204204
</Flex>
205205
<div className="-mx-5 mt-1">
206206
{tabs ? (
207-
<TabGroup value={tabs.value} onChange={tabs.setValue}>
208-
{tabs.items.map((tab, index) => (
209-
<Tab
210-
key={index}
211-
label={tab.label}
212-
disabled={tab.disabled}
213-
hidden={tab.hidden}
214-
toolTipProps={tab.toolTipProps}
215-
/>
216-
))}
207+
<TabGroup value={tabs?.value} onChange={tabs?.setValue}>
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+
})}
217219
</TabGroup>
218220
) : (
219221
<Divider className="mt-3" light />

0 commit comments

Comments
 (0)