From 311c3881f5d0f879f13fa61c49d54a42d792a906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Magalha=CC=83es?= Date: Fri, 31 Jul 2015 10:58:06 +0100 Subject: [PATCH] option to not prevent key events --- src/typeahead/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/typeahead/index.js b/src/typeahead/index.js index 0e220edb..fbf6bd61 100644 --- a/src/typeahead/index.js +++ b/src/typeahead/index.js @@ -31,6 +31,7 @@ var Typeahead = React.createClass({ placeholder: React.PropTypes.string, textarea: React.PropTypes.bool, inputProps: React.PropTypes.object, + preventKeyEvents: React.PropTypes.bool, onOptionSelected: React.PropTypes.func, onChange: React.PropTypes.func, onKeyDown: React.PropTypes.func, @@ -66,6 +67,7 @@ var Typeahead = React.createClass({ placeholder: "", textarea: false, inputProps: {}, + preventKeyEvents: true, onOptionSelected: function(option) {}, onChange: function(event) {}, onKeyDown: function(event) {}, @@ -277,7 +279,9 @@ var Typeahead = React.createClass({ return this.props.onKeyDown(event); } // Don't propagate the keystroke back to the DOM/browser - event.preventDefault(); + if (this.props.preventKeyEvents) { + event.preventDefault(); + } }, componentWillReceiveProps: function(nextProps) {