nanostores / router

A tiny (673 bytes) router for Nano Stores state manager
MIT License
246 stars 19 forks source link

Lit route links handling page refresh #23

Open khmyznikov opened 1 year ago

khmyznikov commented 1 year ago

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 commented 1 year ago

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