diff --git a/packages/components/tabs/__tests__/tabs.test.tsx b/packages/components/tabs/__tests__/tabs.test.tsx
index 9bfa6b8173..727f580f1d 100644
--- a/packages/components/tabs/__tests__/tabs.test.tsx
+++ b/packages/components/tabs/__tests__/tabs.test.tsx
@@ -1,4 +1,4 @@
-import { nextTick, ref } from 'vue'
+import { defineComponent, nextTick, ref } from 'vue'
import { mount } from '@vue/test-utils'
import { describe, expect, test, vi } from 'vitest'
import { EVENT_CODE } from '@element-plus/constants'
@@ -8,6 +8,19 @@ import TabNav from '../src/tab-nav'
import type { TabPaneName } from '../src/tabs'
import type { TabsPaneContext } from '@element-plus/tokens'
+const Comp = defineComponent({
+ components: {
+ TabPane,
+ },
+ setup() {
+ return () => (
+
+ Tab 1 content
+
+ )
+ },
+})
+
describe('Tabs.vue', () => {
test('create', async () => {
const wrapper = mount(() => (
@@ -754,4 +767,17 @@ describe('Tabs.vue', () => {
expect(navItemsWrapper[2].classes('is-active')).toBe(true)
expect(navItemsWrapper[3].classes('is-active')).toBe(false)
})
+
+ test('tab-pane nested', async () => {
+ const wrapper = mount(() => (
+
+
+
+ ))
+
+ const panesWrapper = wrapper.findAllComponents(TabPane)
+ await nextTick()
+
+ expect(panesWrapper.length).toBe(1)
+ })
})
diff --git a/packages/utils/vue/vnode.ts b/packages/utils/vue/vnode.ts
index 8248934962..21b5a18dd8 100644
--- a/packages/utils/vue/vnode.ts
+++ b/packages/utils/vue/vnode.ts
@@ -159,6 +159,9 @@ export const flattedChildren = (
result.push(...flattedChildren(child.children))
} else {
result.push(child)
+ if (isVNode(child) && child.component?.subTree) {
+ result.push(...flattedChildren(child.component.subTree))
+ }
}
})
return result