From 959e8e60122753a87db6a72100123d47d366468b Mon Sep 17 00:00:00 2001 From: Andrew Bartkus Date: Sat, 5 Mar 2016 01:20:54 -0800 Subject: [PATCH] [bug] Fix cursor-jumping in text inputs Working around https://github.com/facebook/react/issues/955 by forcing a synchronous rerender on each keystroke, instead of letting PersistentCharacterStore defer the publication of its state change. --- js/ex3/actions/CharActions.js | 9 +++++---- js/ex3/components/PersistentCharacterEditor.jsx | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/js/ex3/actions/CharActions.js b/js/ex3/actions/CharActions.js index 65b06ad..071c45c 100644 --- a/js/ex3/actions/CharActions.js +++ b/js/ex3/actions/CharActions.js @@ -1,12 +1,13 @@ var reflux = require('reflux'); -module.exports = reflux.createActions([ +const CharActions = module.exports = reflux.createActions([ "add", "remove", // TODO: Change to delete? "update", "save", "load", - - "setName", - "setPortrait", ]); + +['setName', 'setPortrait'].forEach((a) => { + CharActions[a] = reflux.createAction({sync: true}); +}); \ No newline at end of file diff --git a/js/ex3/components/PersistentCharacterEditor.jsx b/js/ex3/components/PersistentCharacterEditor.jsx index 3f202c5..5ac8d4a 100644 --- a/js/ex3/components/PersistentCharacterEditor.jsx +++ b/js/ex3/components/PersistentCharacterEditor.jsx @@ -53,7 +53,7 @@ export default React.createClass({ name: evt.target.value, }); - this.forceUpdate(); + // this.forceUpdate(); }, _portraitImageOnDrop: function(evt) {