-
-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Hi, @ciscoheat! I have a question and a minor suggestion to doc update. @endigo9740 suggested to also post the Q here, so maybe you could suggest better way to handle it or confirm if my assumption and handling is alright.
While migrating to Skeleton V3, discovered issue, which took very long time to discover and only could pin it down thanks to unforeseen $state.snapshot warning from Skeleton V3. So maybe some update to docs could be necessary.
The issue is described here skeletonlabs/skeleton#3213
Summary
I have modal form, which can open another modal form on top of it (like create a new object to reference in the first form). When the response (success) arrives from the second form action, this would close all of the modal forms.
My guess
My assumption is that when the superforms receives the success response, it executes sveltekit's applyAction (if disabled via the options, this does not happen) and the sveltekit (per docs https://svelte.dev/docs/kit/form-actions#Progressive-enhancement-Customising-use:enhance) resets the focus to <body>, which causes all of skeleton modals (zag.js) to change state to open=false and close accordingly. (BTW this does not happen if error arrives, so I guess applyAction is not executed on error).
My fix/handling
After reading docs on superforms, skeleton, and sveltekit, I set applyAction = false in the superform option function. Reasoning (post fact :)): my form is in the modal and does not exactly belong to that particular page (especially form on top of form, which belongs to another route path semantically). So no need to update the page .status & .form in this case.
My question
Would you please take a look at the case and suggest if the assumption and handling is ok? Maybe you could give more insight, why this is happening?
My suggestion
Update docs around applyAction to mention that in case forms are used in popup/modal/dialogs/similar they may disappear, if applyAction is enabled.
Thank you!
K