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

Commit 1e6aa85

Browse files
committed
#46 Handle keyboard navigation the same way as clicking on steps
1 parent 7c64ff4 commit 1e6aa85

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/components/FormWizard.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<wizard-step :tab="tab"
2222
:step-size="stepSize"
2323
@click.native="navigateToTab(index)"
24-
@keyup.enter.native="navigateOrGoToNext(index)"
24+
@keyup.enter.native="navigateToTab(index)"
2525
:transition="transition"
2626
:index="index">
2727
</wizard-step>
@@ -213,7 +213,7 @@
213213
},
214214
addTab (item) {
215215
const index = this.$slots.default.indexOf(item.$vnode)
216-
item.tabId = `t-${item.title}${index}`
216+
item.tabId = `t-${item.title.replace(/ /g, '')}${index}`
217217
this.tabs.splice(index, 0, item)
218218
// if a step is added before the current one, go to it
219219
if (index < this.activeTabIndex + 1) {
@@ -259,13 +259,6 @@
259259
}
260260
return index <= this.maxStep
261261
},
262-
navigateOrGoToNext (index) {
263-
if (!this.navigateToTab(index)) {
264-
for (let i = this.activeTabIndex; i < index; i++) {
265-
this.nextTab()
266-
}
267-
}
268-
},
269262
nextTab () {
270263
let cb = () => {
271264
if (this.activeTabIndex < this.tabCount - 1) {
@@ -292,8 +285,10 @@
292285
focusNextTab () {
293286
let tabIndex = getFocusedTabIndex(this.tabs)
294287
if (tabIndex !== -1 && tabIndex < this.tabs.length - 1) {
295-
let toFocusId = this.tabs[tabIndex + 1].tabId
296-
findElementAndFocus(toFocusId)
288+
let tabToFocus = this.tabs[tabIndex + 1]
289+
if (tabToFocus.checked) {
290+
findElementAndFocus(tabToFocus.tabId)
291+
}
297292
}
298293
},
299294
focusPrevTab () {

src/components/WizardStep.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a>
55
<div class="wizard-icon-circle md"
66
role="tab"
7-
tabindex="0"
7+
:tabindex="tab.checked ? 0 : -1"
88
:id="tab.tabId"
99
:aria-controls="tab.title"
1010
:aria-disabled="tab.active"

0 commit comments

Comments
 (0)