Merge pull request #10702 from codyrancher/workload-title-fix

Making sure tabTitle updates if the content of a slot updates
This commit is contained in:
codyrancher 2024-03-27 09:07:06 -07:00 committed by GitHub
commit ba94731a93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 15 deletions

View File

@ -27,10 +27,11 @@ export default {
default: true
}
},
computed: {
...mapGetters(['isExplorer', 'currentCluster', 'currentProduct']),
computed: { ...mapGetters(['isExplorer', 'currentCluster', 'currentProduct']) },
title() {
methods: {
// This isn't a computed prop because it would trigger a recompute when the $slots changed
computeTitle() {
if (!this.$slots.default || this.$slots.default.length !== 1 || this.$slots.default[0].tag || (typeof this.$slots.default[0].text !== 'string')) {
console.error('The <TabTitle> component only supports text as the child.'); // eslint-disable-line no-console
@ -56,13 +57,9 @@ export default {
}
return breadcrumb;
}
},
methods: {
updatePageTitle() {
updatePageTitle(...this.title);
updatePageTitle(...this.computeTitle());
}
},
@ -70,12 +67,6 @@ export default {
this.updatePageTitle();
},
watch: {
title() {
this.updatePageTitle();
}
},
// Using the render function instead of <template> because <template><slot /></template> will yield a compiler error since
// <slot /> is not allowed to be a root node of a <template> and I don't want to wrap the child to avoid affecting existing styling
render() {
@ -85,6 +76,8 @@ export default {
});
}
this.updatePageTitle();
return this.showChild ? this.$slots.default : null;
}
};