Skip to content

Commit 491d698

Browse files
emanuelmutschlechnerpi0
authored andcommitted
fix(tabs): rename prop to no-key-nav, update docs
1 parent 40ff380 commit 491d698

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/components/tabs/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export default {
296296
```
297297

298298
## Keyboard Navigation
299-
Enable optional keyboard navigation by setting the prop `key-nav`.
299+
Keyboard navigation is enabled by default.
300300

301301
| Keypress | Action
302302
| -------- | ------
@@ -307,6 +307,13 @@ Enable optional keyboard navigation by setting the prop `key-nav`.
307307
| <kbd>TAB</kbd> | Move to the next control on the page
308308
| <kbd>SHIFT</kbd>+<kbd>TAB</kbd> | Move to the previous control on the page
309309

310+
Disable it by setting the prop `no-key-nav`. Behavior will now default to standard browser navigation with TAB key.
311+
312+
| Keypress | Action
313+
| -------- | ------
314+
| <kbd>TAB</kbd> | Move to the next tab or control on the page
315+
| <kbd>SHIFT</kbd>+<kbd>TAB</kbd> | Move to the previous tab or control on the page
316+
310317
**Caution:** If you have text or text-like inputs in your tabs, leave keyboard navigation off,
311318
as it is not possble to use key presses to jump out of a text (or test-like) inputs.
312319

src/components/tabs/tabs.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const bTabButtonHelper = {
1616
disabled: { type: Boolean, default: false },
1717
linkClass: { default: null },
1818
itemClass: { default: null },
19-
keyNav: { type: Boolean, default: true }
19+
noKeyNav: { type: Boolean, default: false }
2020
},
2121
render (h) {
2222
const link = h('a', {
@@ -27,7 +27,7 @@ const bTabButtonHelper = {
2727
],
2828
attrs: {
2929
role: 'tab',
30-
tabindex: this.keyNav ? '-1' : null,
30+
tabindex: this.noKeyNav ? null : '-1',
3131
href: this.href,
3232
id: this.id,
3333
disabled: this.disabled,
@@ -53,7 +53,7 @@ const bTabButtonHelper = {
5353
evt.preventDefault()
5454
evt.stopPropagation()
5555
}
56-
if (evt.type !== 'click' && !this.keyNav) {
56+
if (evt.type !== 'click' && this.noKeyNav) {
5757
return
5858
}
5959
if (this.disabled) {
@@ -91,7 +91,7 @@ export default {
9191
controls: this.safeId('_BV_tab_container_'),
9292
linkClass: tab.titleLinkClass,
9393
itemClass: tab.titleItemClass,
94-
keyNav: this.keyNav
94+
noKeyNav: this.noKeyNav
9595
},
9696
on: {
9797
click: evt => {
@@ -121,7 +121,7 @@ export default {
121121
],
122122
attrs: {
123123
role: 'tablist',
124-
tabindex: this.keyNav ? '0' : null,
124+
tabindex: this.noKeyNav ? null : '0',
125125
id: this.safeId('_BV_tab_controls_')
126126
},
127127
on: { keydown: this.onKeynav }
@@ -230,6 +230,10 @@ export default {
230230
type: Boolean,
231231
default: false
232232
},
233+
noKeyNav: {
234+
type: Boolean,
235+
default: false
236+
},
233237
lazy: {
234238
// This prop is sniffed by the tab child
235239
type: Boolean,
@@ -246,10 +250,6 @@ export default {
246250
navWrapperClass: {
247251
type: [String, Array, Object],
248252
default: null
249-
},
250-
keyNav: {
251-
type: Boolean,
252-
default: true
253253
}
254254
},
255255
watch: {
@@ -293,7 +293,7 @@ export default {
293293
* handle keyboard navigation
294294
*/
295295
onKeynav (evt) {
296-
if (!this.keyNav) {
296+
if (this.noKeyNav) {
297297
return
298298
}
299299
const key = evt.keyCode

0 commit comments

Comments
 (0)