Skip to content

Commit

Permalink
Merge pull request #4 from the-unsullied/fix-ie11-onchange
Browse files Browse the repository at this point in the history
Using onInput on IE11 and onChange on all other browsers
  • Loading branch information
pts-izepeda authored May 25, 2017
2 parents e1ade18 + 2fb2ae0 commit 0a734fc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/FancyField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ import classnames from 'classnames';
import immutable, {fromJS} from 'immutable';

const fromTypeahead = 'FROM_TYPEAHEAD';
const isIE11 = !(window.ActiveXObject) && "ActiveXObject" in window;

function isImmutable(obj) {
return obj !== null && typeof obj === "object" && !!obj.toJSON;
}

function getInputOnChangeProps(handler) {
return isIE11 ? { onInput: handler } : { onChange: handler };
}

export default React.createClass({
listEl: null,
fancyFieldEl: null,
Expand Down Expand Up @@ -394,6 +399,7 @@ export default React.createClass({
aria-invalid={shouldShowError}
ref={(el) => this.fancyFieldEl = el}
placeholder={placeholder}
{...getInputOnChangeProps(this.handleChange)}
onChange={this.handleChange}
onBlur={this.handleBlur}
onFocus={this.handleFocus}
Expand Down

0 comments on commit 0a734fc

Please sign in to comment.