Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,28 @@ var input = React.createFactory('input');
module.exports = React.createClass({

propTypes: {
/**
* Called when the combobox's input receives focus and the user begins interacting with it.
*
* Signature:
*
* ```js
* function(userInput){}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These would not be userInput, but the focus/blur events.

Copy link

@yashafromrussia yashafromrussia Oct 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  handleInputFocus: function() {
    this.props.onFocus();
    this.maybeShowList();
  },

This is not receiving or passing the focus event. I'm using onBlur to do error handling. So it is required for the event to be passed into this.props.onBlur(). To keep it consistent, the onFocus code should probably be something like the following?

  handleInputFocus: function(event) {
    this.props.onFocus(event);
    this.maybeShowList();
  },

* ```
*/
onFocus: React.PropTypes.func,

/**
* Called when the combobox's input loses focus after being activated for user input
*
* Signature:
*
* ```js
* function(userInput){}
* ```
*/
onBlur: React.PropTypes.func,

/**
* Called when the combobox receives user input, this is your chance to
* filter the data and rerender the options.
Expand Down Expand Up @@ -47,6 +67,7 @@ module.exports = React.createClass({
return {
autocomplete: 'both',
onFocus: k,
onBlur: k,
onInput: k,
onSelect: k,
value: null,
Expand Down Expand Up @@ -187,6 +208,7 @@ module.exports = React.createClass({
return;
this.maybeSelectAutocompletedOption();
this.hideList();
this.props.onBlur();
},

handleOptionBlur: function() {
Expand Down
8 changes: 8 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = React.createClass({
isLoading: React.PropTypes.bool,
loadingComponent: React.PropTypes.any,
onFocus: React.PropTypes.func,
onBlur: React.PropTypes.func,
onInput: React.PropTypes.func.isRequired,
onSelect: React.PropTypes.func.isRequired,
tokenAriaFunc: React.PropTypes.func,
Expand Down Expand Up @@ -38,6 +39,12 @@ module.exports = React.createClass({
}
},

handleBlur: function() {
if (this.props.onBlur) {
this.props.onBlur();
}
},

handleInput: function(inputValue) {
this.props.onInput(inputValue);
},
Expand Down Expand Up @@ -87,6 +94,7 @@ module.exports = React.createClass({
'aria-label': this.props['combobox-aria-label'],
ariaDisabled: isDisabled,
onFocus: this.handleFocus,
onBlur: this.handleBlur,
onInput: this.handleInput,
showListOnFocus: this.props.showListOnFocus,
onSelect: this.handleSelect,
Expand Down