From df3e80b7c3fc91cbd62764be467d1dfe28b4b299 Mon Sep 17 00:00:00 2001 From: taehoon Date: Fri, 9 Aug 2019 23:48:08 -0400 Subject: use key prop instead of dataset to identify active tab --- src/components/search/search.vue | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/components/search/search.vue') diff --git a/src/components/search/search.vue b/src/components/search/search.vue index 4350e672..eb20973b 100644 --- a/src/components/search/search.vue +++ b/src/components/search/search.vue @@ -34,18 +34,15 @@ :custom-active="currenResultTab" > -- cgit v1.2.3-70-g09d2 From 6e51774ccbc2628177b43126f089cfdc24acf713 Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 10 Aug 2019 00:26:29 -0400 Subject: use better name of controlled prop --- src/components/search/search.vue | 2 +- src/components/tab_switcher/tab_switcher.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/components/search/search.vue') diff --git a/src/components/search/search.vue b/src/components/search/search.vue index eb20973b..746bbaa2 100644 --- a/src/components/search/search.vue +++ b/src/components/search/search.vue @@ -31,7 +31,7 @@ _.tag) @@ -26,12 +26,12 @@ export default Vue.component('tab-switcher', { } }, 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 + // In case of controlled component + if (this.activeTab) { + return this.$slots.default.findIndex(slot => this.activeTab === slot.key) === index + } else { + return this.active === index + } } }, render (h) { @@ -47,7 +47,7 @@ export default Vue.component('tab-switcher', { } if (slot.data.attrs.image) { return ( -
+