fix(Tabs): incorrect change event in some cases (#7461)

This commit is contained in:
neverland
2020-10-31 17:35:33 +08:00
committed by GitHub
parent 836be2c639
commit 0cc11a45e1
4 changed files with 39 additions and 20 deletions
+14 -10
View File
@@ -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);
}
}
},