Skip to content

Commit 3a08d39

Browse files
authored
feat: add tabIndex props for improved keyboard navigation (#87)
1 parent d8d6097 commit 3a08d39

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

components/form/button/Button.es6.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function Button({ label, badge, primary, danger,
1111
onClick, className, buttonRef, id, alternative,
1212
chevron, type, title, round, roundedRectangle,
1313
hasSelection, selected, recording, processing,
14-
highlighted, disabledStyle,
14+
highlighted, disabledStyle, tabIndex
1515
}) {
1616

1717
const renderButtonContent = () => {
@@ -75,6 +75,7 @@ function Button({ label, badge, primary, danger,
7575
ref={buttonRef}
7676
id={id}
7777
title={title}
78+
tabIndex={tabIndex}
7879
>
7980
{renderButtonContent()}
8081

@@ -120,6 +121,7 @@ Button.defaultProps = {
120121
processing: false,
121122
highlighted: false,
122123
disabledStyle: 'light',
124+
tabIndex: 0
123125
}
124126

125127
Button.propTypes = {
@@ -239,6 +241,11 @@ Button.propTypes = {
239241
* Style for the disabled button
240242
*/
241243
disabledStyle: PropTypes.oneOf(['dark', 'light']),
244+
245+
/**
246+
* Sets the tabIndex
247+
*/
248+
tabIndex: PropTypes.number
242249
}
243250

244251
export default Button

components/form/prompt-input/PromptInputTextarea.es6.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import classnames from 'classnames'
44

5-
function PromptInputTextarea ({ className, placeholder, rows, textareaRef, value, onChange, disabled }) {
5+
function PromptInputTextarea ({ className, placeholder, rows, textareaRef, value, onChange, disabled, tabIndex }) {
66
return (
77
<textarea
88
className={classnames('ds-prompt-input__textarea', className)}
@@ -12,6 +12,7 @@ function PromptInputTextarea ({ className, placeholder, rows, textareaRef, value
1212
value={value}
1313
onChange={onChange}
1414
disabled={disabled}
15+
tabIndex={tabIndex}
1516
/>
1617
)
1718
}
@@ -22,7 +23,8 @@ PromptInputTextarea.defaultProps = {
2223
textareaRef: null,
2324
value: '',
2425
onChange: () => {},
25-
disabled: false
26+
disabled: false,
27+
tabIndex: 0
2628
}
2729

2830
PromptInputTextarea.propTypes = {
@@ -35,7 +37,8 @@ PromptInputTextarea.propTypes = {
3537
]),
3638
value: PropTypes.string,
3739
onChange: PropTypes.func,
38-
disabled: PropTypes.bool
40+
disabled: PropTypes.bool,
41+
tabIndex: PropTypes.number
3942
}
4043

4144
export default PromptInputTextarea

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@b12/metronome",
3-
"version": "1.1.29",
3+
"version": "1.1.30",
44
"description": "",
55
"main": "index.es6.js",
66
"scripts": {

0 commit comments

Comments
 (0)