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

Lit route links handling page refresh #23

Open
khmyznikov opened this issue Jun 18, 2023 · 1 comment
Open

Lit route links handling page refresh #23

khmyznikov opened this issue Jun 18, 2023 · 1 comment

Comments

@khmyznikov
Copy link

From the FAQ:
If you need to change URL programmatically you can use openPage or redirectPage

But in reality, it's the only way to not have full page refresh by clicking on routes links in Lit.
It's on purpose or it's a bug?

This is the solution I have ended with to workaround:
<a href="/map" @click="${($event: Event) => { openRoute($event, 'map') }}" title="map">

private openRoute = (event: Event, route: "map") => {
	event.preventDefault();
	openPage(router, route);
}
@ai
Copy link
Member

ai commented Jun 18, 2023

But in reality, it's the only way to not have full page refresh by clicking on routes links in Lit.

It should not be.

This code should catch all <a> clicks and do non-reload route change.

If you subscribed to store, but these events don’t call, please debug it https://github.com/nanostores/router/blob/main/index.js#L215-L218

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