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

Commit

Permalink
#46 Handle keyboard navigation the same way as clicking on steps
Browse files Browse the repository at this point in the history
  • Loading branch information
cristijora committed Sep 27, 2017
1 parent 7c64ff4 commit 1e6aa85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions src/components/FormWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<wizard-step :tab="tab"
:step-size="stepSize"
@click.native="navigateToTab(index)"
@keyup.enter.native="navigateOrGoToNext(index)"
@keyup.enter.native="navigateToTab(index)"
:transition="transition"
:index="index">
</wizard-step>
Expand Down Expand Up @@ -213,7 +213,7 @@
},
addTab (item) {
const index = this.$slots.default.indexOf(item.$vnode)
item.tabId = `t-${item.title}${index}`
item.tabId = `t-${item.title.replace(/ /g, '')}${index}`
this.tabs.splice(index, 0, item)
// if a step is added before the current one, go to it
if (index < this.activeTabIndex + 1) {
Expand Down Expand Up @@ -259,13 +259,6 @@
}
return index <= this.maxStep
},
navigateOrGoToNext (index) {
if (!this.navigateToTab(index)) {
for (let i = this.activeTabIndex; i < index; i++) {
this.nextTab()
}
}
},
nextTab () {
let cb = () => {
if (this.activeTabIndex < this.tabCount - 1) {
Expand All @@ -292,8 +285,10 @@
focusNextTab () {
let tabIndex = getFocusedTabIndex(this.tabs)
if (tabIndex !== -1 && tabIndex < this.tabs.length - 1) {
let toFocusId = this.tabs[tabIndex + 1].tabId
findElementAndFocus(toFocusId)
let tabToFocus = this.tabs[tabIndex + 1]
if (tabToFocus.checked) {
findElementAndFocus(tabToFocus.tabId)
}
}
},
focusPrevTab () {
Expand Down
2 changes: 1 addition & 1 deletion src/components/WizardStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a>
<div class="wizard-icon-circle md"
role="tab"
tabindex="0"
:tabindex="tab.checked ? 0 : -1"
:id="tab.tabId"
:aria-controls="tab.title"
:aria-disabled="tab.active"
Expand Down

0 comments on commit 1e6aa85

Please sign in to comment.