Skip to content

Commit 8183742

Browse files
authored
Merge pull request #322 from devtron-labs/fix/tab-group
fix: TabGroup: onClick preventDefault when tab is in active state
2 parents 54efcbe + 4473f8d commit 8183742

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Common/RJSF/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const parseSchemaHiddenType = (hiddenSchema: HiddenType): MetaHiddenType
166166
const clone = structuredClone(hiddenSchema)
167167
if (typeof clone === 'string') {
168168
return {
169-
value: false,
169+
value: true,
170170
path: conformPathToPointers(clone),
171171
}
172172
}

src/Shared/Components/TabGroup/TabGroup.component.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ const Tab = ({
2929
alignActiveBorderWithContainer,
3030
})[size]
3131

32+
const onClickHandler = (
33+
e: React.MouseEvent<HTMLButtonElement, MouseEvent> &
34+
React.MouseEvent<HTMLAnchorElement, MouseEvent> &
35+
React.MouseEvent<HTMLDivElement, MouseEvent>,
36+
) => {
37+
if (active || e.currentTarget.classList.contains('active')) {
38+
e.preventDefault()
39+
}
40+
props?.onClick(e)
41+
}
42+
3243
const getTabComponent = () => {
3344
const content = (
3445
<>
@@ -49,6 +60,7 @@ const Tab = ({
4960
className={`${tabClassName} dc__no-decor flexbox-col ${disabled ? 'cursor-not-allowed' : ''}`}
5061
aria-disabled={disabled}
5162
{...props}
63+
onClick={onClickHandler}
5264
>
5365
{content}
5466
</Link>
@@ -59,6 +71,7 @@ const Tab = ({
5971
className={`${tabClassName} dc__no-decor flexbox-col tab-group__tab__nav-link ${disabled ? 'cursor-not-allowed' : ''}`}
6072
aria-disabled={disabled}
6173
{...props}
74+
onClick={onClickHandler}
6275
>
6376
{content}
6477
</NavLink>
@@ -79,6 +92,7 @@ const Tab = ({
7992
className={`dc__unset-button-styles flexbox-col ${tabClassName} ${disabled ? 'cursor-not-allowed' : ''}`}
8093
disabled={disabled}
8194
{...props}
95+
onClick={onClickHandler}
8296
>
8397
{content}
8498
</button>

0 commit comments

Comments
 (0)