From 518ba60b3a0b29213d9f9cce412b178513435719 Mon Sep 17 00:00:00 2001 From: Esteban Brenes Date: Thu, 30 Mar 2017 23:37:31 -0600 Subject: [PATCH] Fix for #76 - Added unit test for tab index - Added documentation - Added examples --- README.md | 4 ++++ example/app.jsx | 35 +++++++++++++++++++++++++++++++++++ src/index.jsx | 5 ++++- test/core.test.jsx | 18 ++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 456a0e6..1d03e8b 100755 --- a/README.md +++ b/README.md @@ -198,6 +198,10 @@ DatePicker component. Renders as a [React-Bootstrap InputGroup](https://react-bo * **Optional** * **Type:** `React.Component` * **Example:** `` + * `tabIndex` - The tabIndex specifies the tab order of the input element. If a `customControl` is used, this property is passed down to it as well. + * **Optional** + * **Type:** `number` + * **Example:** `2` * **Methods:** diff --git a/example/app.jsx b/example/app.jsx index 06a74b6..7fc5014 100755 --- a/example/app.jsx +++ b/example/app.jsx @@ -390,6 +390,41 @@ const App = React.createClass({ + + +

Tab Indexes

+ +
+ + + + Third + + The focus will jump here after Second + + + + + Second + + The focus will jump here after First. + + + + + Fourth + + The focus will jump here after Third + + + + + First + + Focus on this element to start! + + + ; } }); diff --git a/src/index.jsx b/src/index.jsx index d71e97b..786e7d5 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -265,7 +265,8 @@ export default React.createClass({ children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.node), React.PropTypes.node - ]) + ]), + tabIndex: React.PropTypes.number }, getDefaultProps() { @@ -590,6 +591,7 @@ export default React.createClass({ className: this.props.className, style: this.props.style, autoComplete: this.props.autoComplete, + tabIndex: this.props.tabIndex }) : ; return + + ; + } + }); + yield new Promise(function(resolve, reject){ + ReactDOM.render(, container, resolve); + }); + const inputElement = document.querySelector("input.form-control"); + TestUtils.Simulate.focus(inputElement); + assert.notEqual(inputElement, null); + assert.equal(inputElement.getAttribute('tabindex'), 101); + ReactDOM.unmountComponentAtNode(container); + })); });