-
Notifications
You must be signed in to change notification settings - Fork 55
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
Input caret will jump to end of string when using store #178
Comments
You can also see this behaviour with the advanced-scoped-flow in it's stock form while using the input component. |
Ha, good catch, I've never known of this gotcha. It's related to facebook/react#955 |
What do you think about a const actions = {
setName:
(name: string): Action<State> =>
({ setState }) => {
flushSync(() => {
setState({ name: name });
});
},
}; Or an alternative could be adding a second, optional argument to const actions = {
setName:
(name: string): Action<State> =>
({ setState }) => {
setState({ name: name }, { sync: true });
},
}; |
So for reference we are talking about flushSync in Given the Having a function scope where the synchronous event occurs is useful in that arbitrary other operations can be located there be known to be synchronous. In comparison the additional arguments on the |
Is there anyone fixing this bug? v2.7.2 is completely unusable because of this. |
Using the basic-flow example and adding a name to the state:
And an action to set the name:
And a simple input component to the CounterHook component:
If text is added to the beginning, or middle of the name field, the first character will be correct, but the caret will jump to the end of the text after a single entry.
This is not the behaviour if I make a local state using
React.useState
Here is a video of the behaviour:
Screen.Recording.2022-09-22.at.12.38.05.PM.mov
The text was updated successfully, but these errors were encountered: