Skip to content

Commit

Permalink
Fix React 15.2 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgio committed Jul 19, 2016
1 parent 19153f0 commit 23260ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"dependencies": {
"classnames": "^2.2.0",
"lodash": "^4.12.0",
"react-highlighter": "^0.3.1",
"react-input-autosize": "^0.6.2",
"react-highlighter": "^0.3.3",
"react-input-autosize": "^1.1.0",
"react-onclickoutside": "^4.1.1"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0",
"react-dom": "^0.14.0 || ^15.0.0"
"react": "^0.14.0 || ^15.2.0",
"react-dom": "^0.14.0 || ^15.2.0"
},
"devDependencies": {
"babel": "^6.3.26",
Expand Down
7 changes: 3 additions & 4 deletions src/TokenizerInput.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ const TokenizerInput = React.createClass({
propTypes: {
disabled: PropTypes.bool,
labelKey: PropTypes.string,
/**
* Input element placeholder text.
*/
placeholder: PropTypes.string,
selected: PropTypes.array,
},
Expand Down Expand Up @@ -54,8 +51,8 @@ const TokenizerInput = React.createClass({
tabIndex={-1}>
{selected.map(this._renderToken)}
<AutosizeInput
{...this.props}
className="bootstrap-tokenizer-input"
disabled={disabled}
inputStyle={{
backgroundColor: 'inherit',
border: 0,
Expand All @@ -65,6 +62,8 @@ const TokenizerInput = React.createClass({
padding: 0,
}}
onBlur={this._handleBlur}
onChange={this.props.onChange}
onFocus={this.props.onFocus}
onKeyDown={this._handleKeydown}
placeholder={selected.length ? null : placeholder}
ref="input"
Expand Down
4 changes: 2 additions & 2 deletions src/Typeahead.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ const Typeahead = React.createClass({
case ESC:
case TAB:
// Prevent things like unintentionally closing dialogs.
e.stopPropagation();
this._hideDropdown();
// e.stopPropagation();
// this._hideDropdown();
break;
case RETURN:
if (this.state.showMenu) {
Expand Down
16 changes: 13 additions & 3 deletions src/TypeaheadInput.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React, {PropTypes} from 'react';

import cx from 'classnames';
import {head} from 'lodash';
import {BACKSPACE, RIGHT} from './keyCode';
import {head, pick} from 'lodash';
import {BACKSPACE, RIGHT, TAB} from './keyCode';

/**
* TypeaheadInput
Expand All @@ -20,6 +20,8 @@ const TypeaheadInput = React.createClass({
labelKey: PropTypes.string,
onBlur: PropTypes.func,
onChange: PropTypes.func,
onFocus: PropTypes.func,
placeholder: PropTypes.string,
selected: PropTypes.object,
text: PropTypes.string,
},
Expand All @@ -32,6 +34,12 @@ const TypeaheadInput = React.createClass({

render() {
const {className, disabled, selected, text} = this.props;
const inputProps = pick(this.props, [
'disabled',
'onChange',
'onFocus',
'placeholder',
]);

return (
<div
Expand All @@ -41,7 +49,7 @@ const TypeaheadInput = React.createClass({
style={{outline: 'none'}}
tabIndex={-1}>
<input
{...this.props}
{...inputProps}
className={cx('bootstrap-typeahead-input-main', 'form-control', {
'has-selection': !selected,
})}
Expand Down Expand Up @@ -115,8 +123,10 @@ const TypeaheadInput = React.createClass({

switch (e.keyCode) {
case RIGHT:
case TAB:
// Autocomplete the selection if there's a hint and no selection yet.
if (this._getHintText() && !selected) {
e.stopPropagation();
onAdd && onAdd(head(filteredOptions));
}
break;
Expand Down

0 comments on commit 23260ca

Please sign in to comment.