From df3e80b7c3fc91cbd62764be467d1dfe28b4b299 Mon Sep 17 00:00:00 2001
From: taehoon <th.dev91@gmail.com>
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"
         >
           <span
-            data-tab-dummy
-            data-filter="statuses"
+            key="statuses"
             :label="$t('user_card.statuses') + resultCount('visibleStatuses')"
           />
           <span
-            data-tab-dummy
-            data-filter="people"
+            key="people"
             :label="$t('search.people') + resultCount('users')"
           />
           <span
-            data-tab-dummy
-            data-filter="hashtags"
+            key="hashtags"
             :label="$t('search.hashtags') + resultCount('hashtags')"
           />
         </tab-switcher>
-- 
cgit v1.2.3-70-g09d2


From 6e51774ccbc2628177b43126f089cfdc24acf713 Mon Sep 17 00:00:00 2001
From: taehoon <th.dev91@gmail.com>
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 @@
         <tab-switcher
           ref="tabSwitcher"
           :on-switch="onResultTabSwitch"
-          :custom-active="currenResultTab"
+          :active-tab="currenResultTab"
         >
           <span
             key="statuses"
diff --git a/src/components/tab_switcher/tab_switcher.js b/src/components/tab_switcher/tab_switcher.js
index 816d61eb..f11d96e6 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', 'customActive'],
+  props: ['renderOnlyFocused', 'onSwitch', 'activeTab'],
   data () {
     return {
       active: this.$slots.default.findIndex(_ => _.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 (
-            <div class={ classesWrapper.join(' ')}>
+            <div class={classesWrapper.join(' ')}>
               <button
                 disabled={slot.data.attrs.disabled}
                 onClick={this.activateTab(index)}
@@ -59,7 +59,7 @@ export default Vue.component('tab-switcher', {
           )
         }
         return (
-          <div class={ classesWrapper.join(' ')}>
+          <div class={classesWrapper.join(' ')}>
             <button
               disabled={slot.data.attrs.disabled}
               onClick={this.activateTab(index)}
-- 
cgit v1.2.3-70-g09d2

