aboutsummaryrefslogtreecommitdiff
path: root/src/components/tab_switcher/tab_switcher.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/tab_switcher/tab_switcher.js')
-rw-r--r--src/components/tab_switcher/tab_switcher.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/components/tab_switcher/tab_switcher.js b/src/components/tab_switcher/tab_switcher.js
index 81e4d333..67835231 100644
--- a/src/components/tab_switcher/tab_switcher.js
+++ b/src/components/tab_switcher/tab_switcher.js
@@ -4,7 +4,7 @@ import './tab_switcher.scss'
export default Vue.component('tab-switcher', {
name: 'TabSwitcher',
- props: ['renderOnlyFocused', 'onSwitch'],
+ props: ['renderOnlyFocused', 'onSwitch', 'customActive'],
data () {
return {
active: this.$slots.default.findIndex(_ => _.tag)
@@ -24,6 +24,14 @@ export default Vue.component('tab-switcher', {
}
this.active = index
}
+ },
+ isActiveTab (index) {
+ const customActiveIndex = this.$slots.default.findIndex(slot => {
+ const dataFilter = slot.data && slot.data.attrs && slot.data.attrs['data-filter']
+ return this.customActive && this.customActive === dataFilter
+ })
+
+ return customActiveIndex > -1 ? customActiveIndex === index : index === this.active
}
},
render (h) {
@@ -33,7 +41,7 @@ export default Vue.component('tab-switcher', {
const classesTab = ['tab']
const classesWrapper = ['tab-wrapper']
- if (index === this.active) {
+ if (this.isActiveTab(index)) {
classesTab.push('active')
classesWrapper.push('active')
}