fix(Tabs): incorrect change event in some cases (#7461)
This commit is contained in:
+14
-10
@@ -240,19 +240,23 @@ export default createComponent({
|
||||
},
|
||||
|
||||
setCurrentIndex(currentIndex) {
|
||||
currentIndex = this.findAvailableTab(currentIndex);
|
||||
const newIndex = this.findAvailableTab(currentIndex);
|
||||
|
||||
if (isDef(currentIndex) && currentIndex !== this.currentIndex) {
|
||||
const shouldEmitChange = this.currentIndex !== null;
|
||||
this.currentIndex = currentIndex;
|
||||
this.$emit('input', this.currentName);
|
||||
if (!isDef(newIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newTab = this.children[newIndex];
|
||||
const newName = newTab.computedName;
|
||||
const shouldEmitChange = this.currentIndex !== null;
|
||||
|
||||
this.currentIndex = newIndex;
|
||||
|
||||
if (newName !== this.active) {
|
||||
this.$emit('input', newName);
|
||||
|
||||
if (shouldEmitChange) {
|
||||
this.$emit(
|
||||
'change',
|
||||
this.currentName,
|
||||
this.children[currentIndex].title
|
||||
);
|
||||
this.$emit('change', newName, newTab.title);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user