From 8650f16979f5d35b12be73e630fc20ad486eebd0 Mon Sep 17 00:00:00 2001 From: Eric Giovanola Date: Fri, 20 May 2016 01:53:31 -0700 Subject: [PATCH] Fix tabbing behavior --- package.json | 2 +- src/TokenizerInput.react.js | 19 ++++++++++--------- src/Typeahead.react.js | 11 +++++++---- src/TypeaheadInput.react.js | 18 ++++++++++++------ 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 1f0f5150..09fd3581 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-bootstrap-typeahead", - "version": "0.4.0", + "version": "0.4.1", "description": "React-based typeahead using the Bootstrap theme", "main": "lib/index.js", "directories": { diff --git a/src/TokenizerInput.react.js b/src/TokenizerInput.react.js index 51440bd7..c323a141 100644 --- a/src/TokenizerInput.react.js +++ b/src/TokenizerInput.react.js @@ -6,7 +6,7 @@ import Token from './Token.react'; import cx from 'classnames'; import {findDOMNode} from 'react-dom'; -import keyCode from './keyCode'; +import {BACKSPACE, LEFT, RIGHT} from './keyCode'; /** * TokenizerInput @@ -40,14 +40,14 @@ const TokenizerInput = React.createClass({
+ tabIndex={-1}> {selected.map(this._renderToken)} + style={{outline: 'none'}}>
@@ -89,6 +90,10 @@ const TypeaheadInput = React.createClass({ } }, + _handleBlur(e) { + this.props.onBlur(); + }, + /** * If the containing parent div is focused or clicked, focus the input. */ @@ -100,16 +105,17 @@ const TypeaheadInput = React.createClass({ const {filteredOptions, onAdd, onRemove, selected} = this.props; switch (e.keyCode) { - case keyCode.ESC: + case ESC: + case TAB: this.refs.input.blur(); break; - case keyCode.RIGHT: + case RIGHT: // Autocomplete the selection if there's a hint and no selection yet. if (this._getHintText() && !selected) { onAdd && onAdd(head(filteredOptions)); } break; - case keyCode.BACKSPACE: + case BACKSPACE: // Remove the selection if we start deleting it. selected && onRemove && onRemove(selected); break;