fix(components): [tabs] tab-bar need to adapt to tabs width change (#11731)

* fix(components): [tabs] tab-bar need to adapt to tabs width change

closed #11722

* perf(components): [tabs] tabBar -> tabBarRef
This commit is contained in:
Travis 2023-02-28 13:19:19 +08:00 committed by GitHub
parent d58149f4bb
commit be0ed4de68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,6 +82,8 @@ const TabNav = defineComponent({
const nav$ = ref<HTMLDivElement>()
const el$ = ref<HTMLDivElement>()
const tabBarRef = ref<InstanceType<typeof TabBar>>()
const scrollable = ref<false | Scrollable>(false)
const navOffset = ref(0)
const isFocus = ref(false)
@ -180,6 +182,8 @@ const TabNav = defineComponent({
const update = () => {
if (!nav$.value || !navScroll$.value) return
props.stretch && tabBarRef.value?.update()
const navSize = nav$.value[`offset${capitalize(sizeName.value)}`]
const containerSize =
navScroll$.value[`offset${capitalize(sizeName.value)}`]
@ -388,7 +392,9 @@ const TabNav = defineComponent({
onKeydown={changeTab}
>
{...[
!props.type ? <TabBar tabs={[...props.panes]} /> : null,
!props.type ? (
<TabBar ref={tabBarRef} tabs={[...props.panes]} />
) : null,
tabs,
]}
</div>