diff --git a/src/tab/test/__snapshots__/insert.spec.js.snap b/src/tab/test/__snapshots__/insert.spec.js.snap
index 15b4c1272..bd82b97fe 100644
--- a/src/tab/test/__snapshots__/insert.spec.js.snap
+++ b/src/tab/test/__snapshots__/insert.spec.js.snap
@@ -43,3 +43,21 @@ exports[`insert tab with child component 1`] = `
`;
+
+exports[`insert tab with name dynamically 1`] = `
+
+`;
diff --git a/src/tab/test/insert.spec.js b/src/tab/test/insert.spec.js
index bfd4a3edb..3c28b4053 100644
--- a/src/tab/test/insert.spec.js
+++ b/src/tab/test/insert.spec.js
@@ -26,6 +26,27 @@ test('insert tab dynamically', async () => {
expect(wrapper).toMatchSnapshot();
});
+test('insert tab with name dynamically', async () => {
+ const wrapper = mount({
+ template: `
+
+ 2
+ 1
+
+ `,
+ data() {
+ return {
+ insert: false,
+ active: [{ name: 'foo', title: 'foo' }],
+ };
+ },
+ });
+
+ await later();
+ wrapper.setData({ insert: true });
+ expect(wrapper).toMatchSnapshot();
+});
+
// this case will throw wierd error in index.spec.js
// so separate it
test('insert tab with child component', async () => {
diff --git a/src/tabs/index.js b/src/tabs/index.js
index 44126579d..496790e62 100644
--- a/src/tabs/index.js
+++ b/src/tabs/index.js
@@ -142,7 +142,7 @@ export default createComponent({
},
children() {
- this.setCurrentIndexByName(this.currentName || this.active);
+ this.setCurrentIndexByName(this.active || this.currentName);
this.setLine();
this.$nextTick(() => {