-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Textarea's cursor jumps when changing its value through McFly #51
Comments
@kenwheeler I tested it changing the promise for normal callback (like in versions previous to 0.0.8) and it works fine. Could we add a flag to decide when we want an action to be a promise or when we want to be sync? |
+1, it happens the same to me |
good call, adding a sync flag |
Hey man, thank you! I was playing with it myself but I'm pretty sure you'll find a better approach. Just for fun I'll leave it here: So I make that you can define an action as an array too, like: myAction: [
function(someParam){
return {
actionType: 'CHANGE_TEXT',
text: someParam
}
},
true //Sync! to avoid: https://github.com/kenwheeler/mcfly/issues/51
], Then I change if(actions[a].constructor === Array){
action = new Action(actions[a][0], actions[a][1]);
}else {
action = new Action(actions[a]);
} And well, in the function Action(callback, sync) {
this.callback = callback;
this.sync = sync;
}
function dispatchHelper(payload) {
if (!payload) return reject();
if (!payload.actionType) return reThrow(reject,
"Payload object requires an actionType property"
);
try {
Dispatcher.dispatch(payload);
} catch (error) {
reThrow(reject, error);
}
}
Action.prototype.dispatch=function() {"use strict";
if(this.sync !== true) {
return Promise.resolve(this.callback.apply(this, arguments))
.then(function(payload){
return new Promise(function(resolve, reject){
dispatchHelper(payload);
resolve();
});
});
}else {
var payload = this.callback.apply(this, arguments);
dispatchHelper(payload);
}
}; Does this make sense? |
hey @kenwheeler, any news on this? |
So I came into the same exact issue as this one for reflux: reflux/refluxjs#43
Using Flux flow
Action → Store → View
Like:
The problem is that typing anything when the cursor is not at the end of the box, will make the cursor to jump to the end of that box.
In the link I posted above, looks like that framework has a sync flag to make actions sync and the issue does not appear. I suppose here is happening because our actions are promises?
Any idea on how to solve this? Could we add to McFly a similar flag?
@tomatau did you run into similar issues in your projects?
The text was updated successfully, but these errors were encountered: