Skip to content

Commit

Permalink
#17 Fix repeated tab-change events
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian.jora committed Sep 4, 2017
1 parent 5cbc696 commit 12a2f2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dev/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<div>
<vue-tabs class="card" @on-error="handleError"
<vue-tabs class="card"
@tab-change="handleTabChange"
@on-error="handleError"
v-model="tabName">
<v-tab v-for="(tab, index) in tabList"
:key="tab.name"
Expand Down Expand Up @@ -28,6 +30,9 @@
handleError(error){
this.error = error
},
handleTabChange(tabIndex, newTab, oldTab){
console.log(tabIndex, newTab.title, oldTab.title)
},
goToSecondTab(){
this.tabName='name2'
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/VueTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export default{
},
findTabAndActivate (tabNameOrIndex) {
let indexToActivate = this.tabs.findIndex((tab, index) => tab.title === tabNameOrIndex || index === tabNameOrIndex)
if (indexToActivate != -1) {
if (indexToActivate === this.activeTabIndex) return
if (indexToActivate !== -1) {
this.changeTab(this.activeTabIndex, indexToActivate)
} else {
this.changeTab(this.activeTabIndex, 0)
Expand Down Expand Up @@ -139,7 +140,6 @@ export default{
this.renderTabTitle(index, this.textPosition)
}
<a href="javascript:void(0)"
onClick={() => this.navigateToTab(index)}
style={active ? this.activeTabStyle : {}}
class={{'active_tab': active}}
aria-selected={active}
Expand Down

0 comments on commit 12a2f2c

Please sign in to comment.