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?] V3 Modal sveltekit's applyAction closes all modals #3213

Open
ktarmyshov opened this issue Feb 11, 2025 · 1 comment
Open

[bug?] V3 Modal sveltekit's applyAction closes all modals #3213

ktarmyshov opened this issue Feb 11, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@ktarmyshov
Copy link

Current Behavior

I have modal form, which in case can open another modal form (to add a new object and save the returned ID from the server). I am using sveltekit-superforms. When the form action is submitted and response arrives, the sveltekit's applyAction is called (https://svelte.dev/docs/kit/form-actions#Progressive-enhancement-Customising-use:enhance). This causes all of open dialogs to close (property open is set to false).

Image

The warning is not directly relevant to the issue, but helped to nail down the issue. I tried disabling the execution of applyAction in sveltekit-superforms - after that Modals do not get closed, unless I close them (programmatically).

Expected Behavior

I guess the applyAction (form actions) should not have such effect on the Modal.

Steps To Reproduce

Open modal dialog with form (sveltekit-superforms) and submit with success.

Link to Reproduction / Stackblitz

No response

More Information

No response

@ktarmyshov ktarmyshov added the bug Something isn't working label Feb 11, 2025
@endigo9740
Copy link
Contributor

endigo9740 commented Feb 11, 2025

Hey @ktarmyshov not sure how much we do can here. If you're using use:enhanced that's supposed to prevent a page refresh, which would definitely flush all ephemeral state such as modals. I'm not really sure the mechanics of SvelteKit forms, especially with third party tooling like Superform in the mix.

That said, the creator of SuperForms (Cisco) is extremely friendly and does a great job with support. You might consider opening a similar ticket on their side, and/or reaching out in their Discord. They tend to be very active like us.

I can almost promise they'll be able to look into this sooner than we can, but provide better insight into the mechanics happening under the hood during form submission. Keep in mind that our current Svelte-only popover modals are functionally very similar to the native <dialog> or <popover> elements. Both of which would likely suffer from the exact same issue.

You might reference that when explaining the issue so it's clear exactly what's happening, which is: on submission the element and/or component state within forms is being reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants