()
const barStyle = ref()
-const shouldDisableInitialTransition = computed(
+/**
+ * when defaultValue is not set, the bar is always shown.
+ *
+ * when defaultValue is set, the bar will be hidden until style is calculated
+ * to avoid the bar showing in the wrong position on initial render.
+ */
+const renderActiveBar = computed(
() =>
- isUndefined(rootTabs.props.modelValue) &&
- !isUndefined(rootTabs.props.defaultValue)
-)
-const shouldRenderBar = computed(
- () =>
- !shouldDisableInitialTransition.value || Boolean(barStyle.value?.transform)
+ isUndefined(rootTabs.props.defaultValue) ||
+ Boolean(barStyle.value?.transform)
)
const getBarStyle = (): CSSProperties => {
diff --git a/packages/components/tabs/src/tabs.tsx b/packages/components/tabs/src/tabs.tsx
index 3781eb39b4..5b1a294ab4 100644
--- a/packages/components/tabs/src/tabs.tsx
+++ b/packages/components/tabs/src/tabs.tsx
@@ -218,15 +218,6 @@ const Tabs = defineComponent({
(modelValue) => setCurrentName(modelValue)
)
- watch(
- () => props.defaultValue,
- (defaultValue) => {
- if (isUndefined(props.modelValue)) {
- setCurrentName(defaultValue)
- }
- }
- )
-
watch(currentName, async () => {
await nextTick()
nav$.value?.scrollToActiveTab()