-
Notifications
You must be signed in to change notification settings - Fork 43
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
svelte / setFields not working #226
Comments
Hey! Do you have a REPL reproduction? This works for me in the REPL: https://svelte.dev/repl/bb45eaf5b54745d98ea074167e278bdd?version=3.55.1 What are you trying to do? |
@pablo-abc here is a modified version of something I'm trying to do with felte's setFields and havent been able to do it gracefully. https://svelte.dev/repl/284ff1438c6a4990ac370b2db27efaee?version=3.55.1 To workaround this I had to call setFields for both inputs. |
Seems |
Seems the functionality is broken when the form isn't yet rendered. Attempting to set the fields of a form that's not yet connected to the DOM will throw no errors, but have no effect. It may be necessary to create the form before connecting it to the dom, for example, to pass to other components or to prefill it with data before rendering it to the user. |
That is correct! A form needs to exist and be connected before anything else happens. This has been on my head for a while and it seems I just found why this is happening. The original issue seems to be due to a race condition. Both felte itself and the code in the example are waiting for For this specific example, using Checking if there's a way to handle this scenario is taking me a while so apologies for that.... |
Thanks for clarifying. How does the lack of DOM elements prevent the state from being updated? Couldn't the fields read their values from the store once they're connected to the DOM? |
Describe the bug
Essentially I'm having troubles get the data back in the inputs.
Basically trying to get the field to load the data on editing
Which package/s are you using?
felte (Svelte)
The text was updated successfully, but these errors were encountered: