Skip to content

Commit

Permalink
fix: slot not updating with v-slot (#1026)
Browse files Browse the repository at this point in the history
Co-authored-by: Lee Chase <lee.chase@uk.ibm.com>
  • Loading branch information
lee-chase and lee-chase committed Sep 23, 2020
1 parent ac553a4 commit 2b026c4
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 55 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-combo-box/cv-combo-box.vue
Expand Up @@ -189,7 +189,7 @@ export default {
this.highlighted = this.value ? this.value : this.highlight; // override highlight with value if provided
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
computed: {
Expand Down Expand Up @@ -225,7 +225,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
Expand Down
Expand Up @@ -86,7 +86,7 @@ export default {
mounted() {
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
watch: {
Expand Down Expand Up @@ -121,7 +121,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.hasOverflowMenu = !!((this.overflowMenu && this.overflowMenu.length) || this.$slots['overflow-menu']);
},
onChange() {
Expand Down
Expand Up @@ -55,7 +55,7 @@ export default {
},
},
mounted() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.dataExpandable = !!this.$slots.expandedContent;
this.$parent.$emit('cv:mounted', this);
},
Expand Down
Expand Up @@ -42,7 +42,7 @@ export default {
mounted() {
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
computed: {
Expand All @@ -55,7 +55,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.hasBatchActions = !!this.$slots['batch-actions'];
this.hasHelperText = !!this.$slots['helper-text'];
this.hasActions = !!this.$slots['actions'];
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-data-table/cv-data-table.vue
Expand Up @@ -276,7 +276,7 @@ export default {
this.updateRowsSelected();
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
computed: {
Expand Down Expand Up @@ -341,7 +341,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.hasBatchActions = !!this.$slots['batch-actions'];
this.hasActions = !!this.$slots.actions;
this.hasToolbar = !!(this.$slots.actions || this.$listeners.search || this.$slots['batch-actions']);
Expand Down
Expand Up @@ -199,7 +199,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(
this.$slots['invalid-message'] ||
(this.invalidMessage && this.invalidMessage.length) ||
Expand Down Expand Up @@ -327,7 +327,7 @@ export default {
// this.cal.setDate([curDate, anotherDate], true);
// }, 2000);
},
beforeUpdate() {
updated() {
this.checkSlots();
},
beforeDestroy() {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-dropdown/cv-dropdown.vue
Expand Up @@ -171,7 +171,7 @@ export default {
this.updateChildren(this.internalValue);
this.checkSlots();
},
beforeUpdate() {
updated() {
document.body.removeEventListener('click', this.checkSlots);
this.checkSlots();
},
Expand Down Expand Up @@ -252,7 +252,7 @@ export default {
}
},
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-modal/cv-modal.vue
Expand Up @@ -121,7 +121,7 @@ export default {
}
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
watch: {
Expand Down Expand Up @@ -163,7 +163,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.hasFooter = !!(this.$slots['primary-button'] || this.$slots['secondary-button']);
this.hasHeaderLabel = !!this.$slots.label;
this.hasSecondary = !!this.$slots['secondary-button'];
Expand Down
Expand Up @@ -252,7 +252,7 @@ export default {
this.highlighted = this.value ? this.value : this.highlight; // override highlight with value if provided
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
computed: {
Expand Down Expand Up @@ -292,7 +292,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
Expand Down
Expand Up @@ -132,7 +132,7 @@ export default {
this.internalValue = this.valueAsString(this.value);
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
watch: {
Expand Down Expand Up @@ -162,7 +162,7 @@ export default {
this.emitValue();
},
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-select/cv-select.vue
Expand Up @@ -115,7 +115,7 @@ export default {
}
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
watch: {
Expand Down Expand Up @@ -152,7 +152,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-text-area/cv-text-area.vue
Expand Up @@ -69,7 +69,7 @@ export default {
mounted() {
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
computed: {
Expand All @@ -85,7 +85,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-text-input/cv-text-input.vue
Expand Up @@ -96,7 +96,7 @@ export default {
mounted() {
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
watch: {
Expand Down Expand Up @@ -131,7 +131,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
Expand Down
Expand Up @@ -103,7 +103,7 @@ export default {
mounted() {
this.checkSlots();
},
beforeUpdate() {
updated() {
this.checkSlots();
},
computed: {
Expand Down Expand Up @@ -133,7 +133,7 @@ export default {
},
methods: {
checkSlots() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-ui-shell/cv-header.vue
Expand Up @@ -32,10 +32,10 @@ export default {
};
},
mounted() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.hasGlobalHeader = !!this.$slots['header-global'];
},
beforeUpdate() {
updated() {
this.hasGlobalHeader = !!this.$slots['header-global'];
},
computed: {
Expand Down
Expand Up @@ -40,7 +40,7 @@ export default {
hasNavIcon: this.$slots['nav-icon'],
};
},
beforeUpdate() {
updated() {
this.hasNavIcon = !!this.$slots['nav-icon'];
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/cv-ui-shell/cv-side-nav-menu.vue
Expand Up @@ -56,10 +56,10 @@ export default {
};
},
mounted() {
// NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
// NOTE: this.$slots is not reactive so needs to be managed on updated
this.hasNavIcon = !!this.$slots['nav-icon'];
},
beforeUpdate() {
updated() {
this.hasNavIcon = !!this.$slots['nav-icon'];
},
computed: {
Expand Down

0 comments on commit 2b026c4

Please sign in to comment.