Skip to content
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

[BUG] - Form state keys should be generated so that multiple instances of the same form can exist on a page #451

Open
mbmjertan opened this issue Sep 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working javascript Pull requests that update Javascript code

Comments

@mbmjertan
Copy link
Collaborator

Currently, Forms uses the form ID as a state key. Example: https://github.com/infinum/eightshift-forms/blob/main/src/Blocks/components/form/assets/state-init.js#L923

If you put more than one instance of the same form on the page, all instances below the first one in the DOM will break (and potentially, even the first instance will) - because they unexpectedly share state.

This results at least in fields not being initialized properly (e.g. Choices doesn't get initialized at all in the second form etc.).

I think we can work around this by giving each form a unique key and using that as the state key.

@mbmjertan mbmjertan added bug Something isn't working javascript Pull requests that update Javascript code labels Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working javascript Pull requests that update Javascript code
Projects
None yet
Development

No branches or pull requests

2 participants