svelte-tabs icon indicating copy to clipboard operation
svelte-tabs copied to clipboard

reactivity on selectedTabIndex not working

Open jdevine opened this issue 4 years ago • 0 comments

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.

jdevine avatar Apr 09 '20 17:04 jdevine