-
-
Notifications
You must be signed in to change notification settings - Fork 2k
GET form triggers an entire page reload if rendered outside of SvelteKit's root #7940
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
Comments
Probably this is working as intended, and should just be documented. We just want to attach event handlers to the SvelteKit root. There was a comment somewhere recently that I can't find about someone realizing they needed to render a modal/popup within the SvelteKit root instead of directly in |
It's a fairly recent change (and not specific to forms — same applies to links): #7763. The second comment on that issue (which I didn't see because the issue was closed) is basically the same as this but in a different form (pun not intended). I think it's generally preferable to do stuff inside the SvelteKit root, but the comment in that other issue mentions Popper. In cases where user components are being moved outside the SvelteKit root by library code, there's not a whole lot we can do. Honestly not sure how to solve this without reverting #7763, which we don't want to do. |
Right, that's exactly what this issue is. Nobody would ever manually render a Svelte form outside of SvelteKit's root. But most modal libraries will do exactly that (or popovers, tooltips, etc). I'd personally much prefer to see SvelteKit prioritize first-class application development over the ability to embed into some other app (ie by seamlessly supporting things like Popovers, tooltips, modals) but that's of course beyond my paygrade. |
I know configuration flags are a wonderful way to increase complexity, and probably the bane of most maintainers' existence, but could this be configurable? Wanting to embed a SvelteKit app into another app doesn't seem like a common, or default use case. Could this root-only event handling be opted into with some sort of embeddable flag? |
Configuration might be the least worst option, I don't know. Marking this as 1.0 milestone because if we were to revert to listening on |
How about a |
Whether we use a config option or |
Then again the existence of a module in the SvelteKit codebase called |
Sorry to drag this a bit down into the weeds amidst this great discussion, but can I ask if the behavior I described above, of (progressively enhanced) form actions working safely, even if the form (and submit button) are outside of the SvelteKit root, is reliable, in the absence of whatever solution you all land on? Ie, is this supposed to work, or does this just happen to work, and might stop working with some possible, non-breaking change in the future. |
What I had in my mind was, that you could have multiple |
Closes #7940 Adds a new option which defaults to false. If true, events related to navigation etc are listened to on the target element rather the html root
Describe the bug
If a form is rendered outside of SvelteKit's content, and triggers a navigation, the entire page reloads.
This might seem like an absurd thing to care about, but a search form inside of a modal, rendered in a portal is a reasonably common occurrence, and exactly how I discovered this.
Incidentally, form actions appear to work fine. You can post from a form rendered in a portal, and the invalidation appears to work correctly, without the full reload
Reproduction
https://github.com/arackaf/svelte-kit-form-nav-repro
First textbox is rendered inside of SvelteKit, and works correctly.
Second one is rendered in a portal, and triggers a full page reload.
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: