mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-27 02:01:15 +08:00
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:
parent
d58149f4bb
commit
be0ed4de68
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user