Jacobs63 / vue3-tabs-component

Vue 3 tabs component
MIT License
95 stars 27 forks source link

Tabs are not updating #6

Closed PabloFacciano closed 2 years ago

PabloFacciano commented 2 years ago

Suppose I have something like this:

<tabs :options="{ useUrlFragment: true }">
  <tab v-for="tab in this.$store.state.tabs" :key="tab.id" :name="tab.name" :id="tab.id">
    <component-a v-if="tab.type == 'a'" />
    <component-b v-if="tab.type == 'b'" />
  </tab>
</tabs>

When I modify the open tabs $store.state.tabs and remove an item, nothing happens with the tabs components.

Within my humble opinion (and I may be wrong), I think a beforeUnmount hook may be missing that removes the tab from the internal state of the tabs component.

At the moment, the only workaround is to reload the tabs component.

Jacobs63 commented 2 years ago

Hello,

after investigating I can confirm that removing a child Tab component was not reflected in the parent's internal state. Thus adding an onBeforeUnmount hook, which removes it from the Tabs component's internal state is a correct approach.

Version 1.0.4 has been released which fixed this issue.

Thank you for your contribution.