Update todo example. fixes 'Create' that shouldn't happen
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() === "")`
Geert-Jan Brits committed
May 29, 2014 at 14:45 UTC
0c312222e9ba61cb04b931de05374d9ba6092504
1 file changed
+4
-1
examples/todomvc-flux/js/components/Header.react.js
+4
-1
@@ -45,7 +45,10 @@ var Header = React.createClass({
45
* @param {string} text
46
*/
47
_onSave: function(text) {
48
- TodoActions.create(text);
48
+ if(text.trim()){
49
+ TodoActions.create(text);
50
+ }
51
+
52
}
53
54
});