diff --git a/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroup.tsx b/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroup.tsx
index c4ec0eeda..fd5662b85 100644
--- a/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroup.tsx
+++ b/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroup.tsx
@@ -1,3 +1,4 @@
+import { Children, isValidElement } from 'react';
import type { ComponentWithRef } from '@vibrant-ui/core';
import { TabView } from '@vibrant-ui/core';
import { HStack } from '../HStack';
@@ -11,29 +12,33 @@ import type { ViewPagerTabGroupProps } from './ViewPagerTabGroupProps';
import { withViewPagerTabGroupVariation } from './ViewPagerTabGroupProps';
export const ViewPagerTabGroup = withViewPagerTabGroupVariation(
- ({ children, tabId, testId, onTabChange, tabSpacing, native_swipeEnabled = true }) => (
- (
-
- {props}
-
- )}
- renderTobBarItem={({ isSelected, onClick, title, tabId }) => (
-
-
- {title}
-
- {isSelected && }
-
- )}
- onTabChange={onTabChange}
- native_swipeEnabled={native_swipeEnabled}
- >
- {children}
-
- )
+ ({ children, tabId, testId, onTabChange, tabSpacing, native_swipeEnabled = true }) => {
+ const validChildren = Children.toArray(children).filter(isValidElement);
+
+ return (
+ (
+
+ {props}
+
+ )}
+ renderTobBarItem={({ isSelected, onClick, title, tabId }) => (
+
+
+ {title}
+
+ {isSelected && }
+
+ )}
+ onTabChange={onTabChange}
+ native_swipeEnabled={native_swipeEnabled}
+ >
+ {validChildren}
+
+ );
+ }
) as ComponentWithRef & {
Item: ComponentWithRef;
};
diff --git a/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroupProps.ts b/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroupProps.ts
index 4992f1bfd..038b9a9fc 100644
--- a/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroupProps.ts
+++ b/packages/vibrant-components/src/lib/ViewPagerTabGroup/ViewPagerTabGroupProps.ts
@@ -3,10 +3,10 @@ import { withVariation } from '@vibrant-ui/core';
import type { ViewPagerTabGroupItemProps } from './ViewPagerTabGroupItem';
export type ViewPagerTabGroupProps = {
- children: ReactElement | ReactElement[];
+ children: (ReactElement | undefined)[] | ReactElement;
tabSpacing?: number;
tabId?: string;
- onTabChange?: () => void;
+ onTabChange?: (tabId?: string) => void;
testId?: string;
native_swipeEnabled?: boolean;
};
diff --git a/packages/vibrant-core/src/lib/TabView/TabView.tsx b/packages/vibrant-core/src/lib/TabView/TabView.tsx
index 1b49837f2..9f6571a1a 100644
--- a/packages/vibrant-core/src/lib/TabView/TabView.tsx
+++ b/packages/vibrant-core/src/lib/TabView/TabView.tsx
@@ -23,7 +23,7 @@ export const TabView = withTabViewVariation(
setCurrentIndex(index);
- onTabChange?.();
+ onTabChange?.(currentTab?.props.tabId);
};
const changeTabById = useCallbackRef((tabId?: string) => {
diff --git a/packages/vibrant-core/src/lib/TabView/TabViewProps.ts b/packages/vibrant-core/src/lib/TabView/TabViewProps.ts
index 5edd0d77b..2eeb6db42 100644
--- a/packages/vibrant-core/src/lib/TabView/TabViewProps.ts
+++ b/packages/vibrant-core/src/lib/TabView/TabViewProps.ts
@@ -8,7 +8,7 @@ type TabViewProps = {
children: ReactElement | ReactElement[];
renderTobBarItem: (_: { title: string; isSelected: boolean; onClick: () => void; tabId: string }) => ReactElement;
renderTobBarContainer: (props: ReactElementChildren) => ReactElement;
- onTabChange?: () => void;
+ onTabChange?: (tabId?: string) => void;
testId?: string;
native_swipeEnabled?: boolean;
};