-
Notifications
You must be signed in to change notification settings - Fork 40
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: dropdowns don't work after hot reload changes to layout file with Svelte #19
Comments
Hi @kunasun
Thank you for your support in helping us improve FlyonUI! We’ve received your submission and will respond within few business days. Our team handles issues one at a time, and we’ll be reviewing yours as soon as possible. In the meantime, any additional details or a reproducible example would be greatly appreciated and will help us resolve the issue more efficiently. Thank you for your patience and understanding! |
Hello @kunasun, Svelte's Hot Module Replacement (HMR) provides the advantage of instantly reflecting file changes without the need for a full page reload. However, when you make modifications to FlyonUI.js depends on specific elements being present in the DOM during its initialization. When the DOM structure changes—such as when To mitigate this problem, you can modify <script>
import { afterNavigate } from "$app/navigation";
import { afterUpdate } from 'svelte';
import "./styles.css";
afterNavigate(() => {
// Runs after navigating between pages
HSStaticMethods.autoInit();
});
afterUpdate(() => {
// Ensures FlyonUI.js is reinitialized after any DOM updates
HSStaticMethods.autoInit();
});
</script> By incorporating this code, you can ensure that FlyonUI.js is properly reinitialized after DOM updates, which should help prevent issues arising from HMR. Note: Feel free to test this in our StackBlitz example. We will also update our documentation to assist other users with similar concerns. Thank you for your feedback! I hope this helps! Let me know if you encounter any further issues. |
Thanks for the quick response! This is working better than before, but I have ran into some more issues. This is using the newly released Svelte5 so there might need to be some other changes to support this. The issue I am encountering now is the same as above but within the Another note: It seems like
|
Any update on this? |
Hello @kunasun, Apologies for the delay in responding to your question, and thank you for pointing out the new changes in Svelte. However, please note that after testing locally and in StackBlitz, we did not encounter any issues when adding the following code to $effect(() => {
window.HSStaticMethods.autoInit();
}); Here is the tested ZIP file for Svelte. |
What version of FlyonUI are you using?
v1.1.0
Which browsers are you seeing the problem on?
All browsers
Reproduction URL
https://stackblitz.com/edit/flyonui-svelte-y2cmpt?file=src%2Froutes%2F%2Bpage.svelte
Describe your issue
I'm working with FlyonUI with SvelteKit and I noticed this issue which can be reproduced in the stackblitz link for the Svelte project template.
In the
src/routes/+layout.svelte
file there are the two dropdowns in the navbar. On first load when running the dev server, the dropdowns work fine. However, if you edit something in the+layout.svelte
file (I edited the FlyonUI text to something else) and then try to interact with the dropdown, it does not work until you refresh the whole browser page.Other notes:
+page.svelte
file does not seem to break the dropdown between hot reloads, so maybe it is only related to the layout files, or only breaks if it hot reloads the component/page that the dropdown is part ofThe text was updated successfully, but these errors were encountered: