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

reactivity on selectedTabIndex not working #7

Open
jdevine opened this issue Apr 9, 2020 · 0 comments
Open

reactivity on selectedTabIndex not working #7

jdevine opened this issue Apr 9, 2020 · 0 comments

Comments

@jdevine
Copy link

jdevine commented Apr 9, 2020

Trying to change tabs from outside the Tabs component by changing the selectedTabIndex prop, but it isn't working.

Not sure if the $: variable, anonymous function syntax is legacy, but it doesn't seem to do anything now. I changed it to a function call containing the variable:

on the Tabs.svelte:

  $: selectedTabIndex, ()=>{
    selectedTab.set(tabs[selectedTabIndex]);
    selectedPanel.set(panels[selectedTabIndex]);
  };

doesn't work

Changing it to

 const setTabAndPanel = (idx) => {
    selectedTab.set(tabs[idx]);
    selectedPanel.set(panels[idx]);
}

$: setTabAndPanel(selectedTabIndex) 

works.

If I can, I'll make a pull request, but it'll be some time.

EnigmaCurry added a commit to EnigmaCurry/svelte-tabs that referenced this issue Jun 7, 2022
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

1 participant