Skip to content

Commit

Permalink
Merge pull request #158 from start940315/develop
Browse files Browse the repository at this point in the history
feat(tabs): update panels after panel comp updated
  • Loading branch information
chaishi authored Dec 31, 2021
2 parents 4cfaf21 + 31eacd2 commit 1089541
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/tabs/tab-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default Vue.extend({
},
},

updated() {
(this.$parent as any)?.updatePanels?.({ force: true });
},

render() {
const { destroyOnHide, active } = this;
if (destroyOnHide && !active) return null;
Expand Down
4 changes: 2 additions & 2 deletions src/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default (Vue as VueConstructor<TabVue>).extend({
},

methods: {
updatePanels() {
updatePanels({ force = false } = {}) {
if (!this.listPanels) {
this.panels = this.panels || [];
return;
Expand All @@ -63,7 +63,7 @@ export default (Vue as VueConstructor<TabVue>).extend({
.filter(Boolean)
.filter((child) => kebabCase(child?.$vnode?.tag).endsWith(`${prefix}-tab-panel`));
const isUnchange = () => newPanels.length === this.panels.length && this.panels.every((panel, index) => panel === newPanels[index]);
if (isUnchange()) return;
if (isUnchange() && !force) return;
this.panels = newPanels;
},
onAddTab(e: MouseEvent) {
Expand Down

0 comments on commit 1089541

Please sign in to comment.