From 147cdbc915344dba166301b17170aa66a9a02c1c Mon Sep 17 00:00:00 2001 From: miketamis Date: Thu, 12 Nov 2015 10:28:16 +1300 Subject: [PATCH] Added the ability to see when a user hits enter. --- src/components/typeahead.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/typeahead.jsx b/src/components/typeahead.jsx index 6d209a5..1895ce8 100644 --- a/src/components/typeahead.jsx +++ b/src/components/typeahead.jsx @@ -44,7 +44,8 @@ module.exports = React.createClass({ onDropdownClose: React.PropTypes.func, optionTemplate: React.PropTypes.func.isRequired, getMessageForOption: React.PropTypes.func, - getMessageForIncomingOptions: React.PropTypes.func + getMessageForIncomingOptions: React.PropTypes.func, + onEnter: React.PropTypes.func }, getDefaultProps: function() { @@ -72,7 +73,8 @@ module.exports = React.createClass({ return ( number + ' suggestions are available. Use up and down arrows to select.' ); - } + }, + onEnter: noop }; }, @@ -411,6 +413,7 @@ module.exports = React.createClass({ _this.focus(); _this.hideHint(); _this.hideDropdown(); + props.onEnter(event, props.options[_this.state.selectedIndex], _this.state.selectedIndex); break; case 'Escape': _this.hideHint();