You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a follow up to #188, which was a slightly different one. I'd like to be able to prevent any route action to happen in some cases and that cannot be solved currently with guards.
The use case is running a svelte app inside of another app or site. Typically in my case, a WordPress or Joomla extension or theme.
As the parent CMS have links that may use hashes as well, such as href='#', this causes svelte-spa-router (SSR) to either trigger a 404 for the app (if I set up a '*" catch-all route) or to clear the app as if no route matches, the component variable is set to null.
I namespaced my routes to avoid conflict with any other #xxx that may exist on the page from the CMS, but I cannot prevent SSR to react to clicks on CMS links, outside of my apps.
If I use a guard and return false when not one my routes, the router does not load any route at all, so I end up with a blank screen.
Either a guard could be made to return true, false or 'cancel' or null to do absolutely nothing instead of killing the component if no route is matched. Just keep the current one, do nothing.
Or the pre-condition should be made able to modify the route somehow.
Note that I also tried:
by using a route guard that fails on some condition. When the condition fails, the router triggers the conditionsFailed event and there you can change the URL
A workaround here would be to set the route back to the previous one, before the click on that external href, but the previous location information has been lost at this stage, the route has already been killed.
Thanks and regards
The text was updated successfully, but these errors were encountered:
This would be handy for the use case I mentioned here: #196 (comment)
In particular, since the querystring is part of the route (though I'm not using it for my routes) any changes to the querystring cause the route to be rerendered. It would be nice to opt out of that so I could use the querystring to keep some page state in the URL.
i'm having the exact same issue as the OP is describing. I'd also like to have simple 'external' links (maybe rel="external" can be excluded somehow from catching every link in the DOM.
This is a follow up to #188, which was a slightly different one. I'd like to be able to prevent any route action to happen in some cases and that cannot be solved currently with guards.
The use case is running a svelte app inside of another app or site. Typically in my case, a WordPress or Joomla extension or theme.
As the parent CMS have links that may use hashes as well, such as href='#', this causes svelte-spa-router (SSR) to either trigger a 404 for the app (if I set up a '*" catch-all route) or to clear the app as if no route matches, the component variable is set to null.
I namespaced my routes to avoid conflict with any other #xxx that may exist on the page from the CMS, but I cannot prevent SSR to react to clicks on CMS links, outside of my apps.
If I use a guard and return false when not one my routes, the router does not load any route at all, so I end up with a blank screen.
Either a guard could be made to return true, false or 'cancel' or null to do absolutely nothing instead of killing the component if no route is matched. Just keep the current one, do nothing.
Or the pre-condition should be made able to modify the route somehow.
Note that I also tried:
A workaround here would be to set the route back to the previous one, before the click on that external href, but the previous location information has been lost at this stage, the route has already been killed.
Thanks and regards
The text was updated successfully, but these errors were encountered: