BUG: FastField causes race condition on Chromes autofill
See original GitHub issueThis is a bug
Current Behavior
When doing autofill (autocomplete) multiple times, FastField
sometimes doesn’t register the change on the field where the autofill is used. At other times, when a new value from autofill is selected, the old one pops right back. I suspect that this is some sort of race condition.
Additional Information
You have to play around with it a little bit to see this happening. Make sure you have at least two autofill options to reproduce and switch between them to see old value appearing.
Video: https://www.youtube.com/watch?v=869xNEs6fe0
- Formik Version: 1.0.0-alpha.4
- React Version: ^16.3.1
- TypeScript Version: None
- CodeSandbox Link: https://codesandbox.io/s/qqlkvpwpz6
- OS: OS X
- Node Version: v8.9.0
- Package Manager and Version: Yarn 1.3.2
- Browser: Chrome 65.0.3325.181
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Is this an autofill bug on Chrome 81? - Super User
1 Answer 1 ... The named fields in an HTML form are stored with their values by the browser in the user's profile,...
Read more >Untitled
Ch mangot vulcin, Dr1-c form, Psp disease causes, Steelheads hockey parking, ... Esmeriles bosch precios, Eastfield avenue alkrington, Nyhetene nett tv, ...
Read more >Untitled
Novia ahogada, Idealista alquiler alcobendas, Red ant like bugs in garden ... Sick around the world pbs full documentary, Sulky racing cart, Lacetti...
Read more >Untitled
Cheap race cars for sale in michigan, Kreissparkasse osterholz vorstand, ... Lei black shoes, Wobbler disease, Sport bakkie accessories south africa, ...
Read more >Untitled
Jenni rivera su adios, Ruby goodyear instagram, Tonsilith cause infection, ... Kiowa casino rewards, Children's books about the space race, 841 sword bridge ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue is due to the fix to allow FastField to accept values from the formik context as it changes. This was needed since you couldn’t imperatively set values using the setFieldX methods, however my suggested fix to add a componentWillReceiveProps method broke a few other things.
It will only happen if auto-fill is changing more than one field but since it doesn’t blur the field that is currently focused after changing it’s value but it does for the other fields, the changes for those fields will propagate up to formik, the focused FastField will receive new props which will contain the previous value and since that is different to it’s current value it will swap back to that.
It’s also an issue if the Form happens to re-render while the user is typing.
I’ve thought about it a little bit and now I would suggest the FastField to be the source of truth for it’s own values and errors rather than the context of the form. This would mean removing the componentWillReceiveProps from FastField and using the same subscription logic as the reset function to setValues and setErrors on FastFields.
I can submit a PR for this soon I just have to get my head around TypeScript a little more to be sure I’m not doing something dumb.
ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we’ll re-open it.