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

use:active breaks when removing a link from an #each #28

Closed
TorstenDittmann opened this issue Oct 3, 2019 · 2 comments
Closed

use:active breaks when removing a link from an #each #28

TorstenDittmann opened this issue Oct 3, 2019 · 2 comments

Comments

@TorstenDittmann
Copy link
Contributor

use:active breaks when removing a link from an #each array.

My example:

{#each testData as testItem}
    <li use:active={testItem.link, 'active' }>
        <a href={testItem.link} use:link>{testItem.name}</a>
        - 
        <i on:click={() => removeData(testItem.id)}>X</i>
    </li>
{/each}

let testData = [
    {
        id: 1,
        name: "link",
        link: "/hello/1"
    },
    {
        id: 2,
        name: "link2",
        link: "/hello/2"
    },
    {
        id: 3,
        name: "link3",
        link: "/hello/3"
    },
];

function removeData(id) {
    testData = testData.filter(data => data.id != id);
}

After a link in the array is removed, the active state remains frozen on the current one and does not change anymore.

Conversely, when a link is added, everything still works. Only if a link with a use:active is removed.

Right now I am looking into the problem...

I forked the example from this project and added code where the error occurs:
https://github.com/TorstenDittmann/svelte-spa-router/tree/master/example

@ItalyPaleAle
Copy link
Owner

Version 1.2.1 is now on NPM with this fix. Thanks for your contribution!

@TorstenDittmann
Copy link
Contributor Author

You are welcome!

freshteapot pushed a commit to freshteapot/svelte-spa-router that referenced this issue Nov 18, 2019
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