tabIndex override implemented

This commit is contained in:
NikolaBorislavovHristov 2019-04-25 13:50:30 +03:00
parent 6d18c05771
commit 8f1a61d3cf

View file

@ -16,7 +16,7 @@ const TAG_NAMES_FOR_TYPE = {
search: 'input'
};
const Input = React.forwardRef(({ type, children, ...props }, ref) => {
const Input = React.forwardRef(({ type, tabIndex, children, ...props }, ref) => {
const onKeyUp = React.useCallback((event) => {
if (typeof props.onKeyUp === 'function') {
props.onKeyUp(event);
@ -56,7 +56,7 @@ const Input = React.forwardRef(({ type, children, ...props }, ref) => {
...props,
ref: ref,
type: tagName === 'input' ? type : null,
tabIndex: focusable ? 0 : -1,
tabIndex: (isNaN(tabIndex) || tabIndex === null) ? (focusable ? 0 : -1) : tabIndex,
onKeyUp: onKeyUp,
onDrag: onDrag,
onMouseOut: onMouseOut
@ -69,6 +69,7 @@ Input.propTypes = {
...BUTTON_INPUT_TYPES,
...TEXT_INPUT_TYPES
]).isRequired,
tabIndex: PropTypes.number,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node