Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
#40 Change on-change event so it triggers only when tabs are actually…
Browse files Browse the repository at this point in the history
… changed
  • Loading branch information
cristijora committed Sep 4, 2017
1 parent 93f1f89 commit 1545883
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/FormWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@
if (index < this.activeTabIndex) {
this.maxStep = this.activeTabIndex - 1
this.activeTabIndex = this.activeTabIndex - 1
this.$emit('on-change', this.activeTabIndex + 1, this.activeTabIndex)
}
tabs.splice(index, 1)
}
},
navigateToTab (index) {
this.$emit('on-change', this.activeTabIndex, index)
let validate = index > this.activeTabIndex
if (index <= this.maxStep) {
let cb = () => {
Expand All @@ -250,7 +250,6 @@
}
},
nextTab () {
this.$emit('on-change', this.activeTabIndex, this.activeTabIndex + 1)
let cb = () => {
if (this.activeTabIndex < this.tabCount - 1) {
this.changeTab(this.activeTabIndex, this.activeTabIndex + 1)
Expand All @@ -262,7 +261,6 @@
this.beforeTabChange(this.activeTabIndex, cb)
},
prevTab () {
this.$emit('on-change', this.activeTabIndex, this.activeTabIndex - 1)
let cb = () => {
if (this.activeTabIndex > 0) {
this.setValidationError(null)
Expand Down Expand Up @@ -323,7 +321,7 @@
callback()
}
},
changeTab (oldIndex, newIndex) {
changeTab (oldIndex, newIndex, emitChangeEvent = true) {
let oldTab = this.tabs[oldIndex]
let newTab = this.tabs[newIndex]
if (oldTab) {
Expand All @@ -332,6 +330,9 @@
if (newTab) {
newTab.active = true
}
if (emitChangeEvent && this.activeTabIndex !== newIndex) {
this.$emit('on-change', oldIndex, newIndex)
}
this.activeTabIndex = newIndex
this.activateTabAndCheckStep(this.activeTabIndex)
return true
Expand Down

0 comments on commit 1545883

Please sign in to comment.