From 2fb2ae03d1ceb9c5c3b16fb1eb69e7fb8f3e6b06 Mon Sep 17 00:00:00 2001 From: Isaac Zepeda Date: Wed, 24 May 2017 18:50:11 -0700 Subject: [PATCH] Using onInput on IE11 and onChange on all other browsers --- src/FancyField.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/FancyField.jsx b/src/FancyField.jsx index 8292095..f4e4a6c 100644 --- a/src/FancyField.jsx +++ b/src/FancyField.jsx @@ -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, @@ -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}