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

Navigate 'active' class is not updated when navigating in SPA #113

Open
CatchABus opened this issue Apr 15, 2021 · 2 comments
Open

Navigate 'active' class is not updated when navigating in SPA #113

CatchABus opened this issue Apr 15, 2021 · 2 comments

Comments

@CatchABus
Copy link
Contributor

CatchABus commented Apr 15, 2021

It seems that class active does not append to next clicked menu item on SPA apps.
It's only updated during browser refresh.

It seems that Navigate component's active class condition is not reactive:
https://github.com/jorgegorka/svelte-router/blob/master/src/components/navigate.svelte#L27

@htmlbanjo
Copy link

If you can tweak your app structure a bit, I've had success with simply reusing the currentRoute prop:

 class:active={currentRoute?.name === '/my/page'}

@htmlbanjo
Copy link

Another option, e.g. a URL structure like: /view/:view/status/:status

let status
$: status = currentRoute?.childRoute?.namedParams?.status

//...
class:active={status === 'string-to-match'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants