From 8eee3e303501fb11631ae1661aeccb28d8f21fdc Mon Sep 17 00:00:00 2001 From: cristijora Date: Mon, 3 Jul 2017 19:11:53 +0300 Subject: [PATCH] Filter based on slot content rather than children (assures component insertion order) --- src/components/FormWizard.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/FormWizard.vue b/src/components/FormWizard.vue index 2329afe..f95b490 100644 --- a/src/components/FormWizard.vue +++ b/src/components/FormWizard.vue @@ -364,7 +364,11 @@ } }, getTabs () { - return this.$children.filter((comp) => comp.$options.name === 'tab-content') + let tabs = this.$slots.default.filter((comp) => comp.componentOptions && comp.componentOptions.tag === 'tab-content') + .map(comp => { + return comp.componentInstance + }) + return tabs }, activateTab (index) { let tab = this.tabs[index] @@ -388,8 +392,12 @@ console.warn(`Prop startIndex set to ${this.startIndex} is greater than the number of tabs - ${this.tabs.length}. Make sure that the starting index is less than the number of tabs registered`) } }, + /*** + * Called when tabs are added dynamically from array + **/ reinitializeTabs () { let currentTabs = this.getTabs() + // The tab count did not change therefore we ignore further checks if (this.tabs.length === 0 || this.tabs.length === currentTabs.length) return this.tabs = currentTabs let oldTabIndex = -1