Skip to content

Commit

Permalink
Update todo example. fixes 'Create' that shouldn't happen
Browse files Browse the repository at this point in the history
Currently, an `onBlur` creates a new todo on `TodoTextInput`. This makes sense for existing items but not for new items. I.e consider the following: 

1. cursor on new item ("What needs to be done?")
2. click 'x' on the first item. 

This results in two actions being fired: 

1. TODO_CREATE, with an empty string as 'text'
2. TODO_DESTROY

The proposed fix doesn't send a TODO_CREATE if `text.trim() === "")`
  • Loading branch information
0xgeert committed May 29, 2014
1 parent 8d8dd4d commit 0c31222
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/todomvc-flux/js/components/Header.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ var Header = React.createClass({
* @param {string} text
*/
_onSave: function(text) {
TodoActions.create(text);
if(text.trim()){
TodoActions.create(text);
}

}

});
Expand Down

0 comments on commit 0c31222

Please sign in to comment.