AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
669 stars 30 forks source link

Promlem with router.goto() and html links #77

Closed gornostay25 closed 2 years ago

gornostay25 commented 2 years ago

This is a part of my code This code is on the "/orders" page

{#each orders as item}
    <tr on:click={e=>router.goto("/order/"+encodeURIComponent(item._id))}>
        <td>{@html badge((item.status==0)?"new":(item.status==1)?"success":"fail")}</td>
        <td><a href="/client/{encodeURIComponent(item.client._id)}">{item.client.name}</a></td>
        <td>{new Intl.NumberFormat('sr', { style: 'currency', currency: 'EUR' }).format(item.total)}</td>
    </tr>
{/each}

When I click on the "tr" element all is well I am redirected to /order/blabla and when I press the button back in the browser, I return to the /orders page But if I use link, and after it press back button i redirected to /order/blabla

AlexxNB commented 2 years ago

Maybe it is because both clicks (tr and anchor) are handled when you clicking on link. Try self modifier with tr handler: on:click|self={...}