Skip to content

Commit dd2164b

Browse files
authored
Fix legendHeight setter in mount (#170)
* Fix legendHeight setter in mount When VueEllipseProgress mounts, it might have `legend` disabled, in which case the `legendHeight` property should be set to `0` rather than trying to access the nonexistent `legend` template ref. * Use method for updateLegendHeight
1 parent 7269cfc commit dd2164b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/VueEllipseProgress.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ export default {
5353
}),
5454
watch: {
5555
hideLegend() {
56-
this.$nextTick(() => {
57-
this.legendHeight = this.hideLegend ? 0 : this.$refs.legend.clientHeight;
58-
});
56+
this.updateLegendHeight();
5957
},
6058
},
6159
computed: {
@@ -111,10 +109,15 @@ export default {
111109
return normalizedCircles;
112110
},
113111
},
112+
methods: {
113+
updateLegendHeight() {
114+
this.$nextTick(() => {
115+
this.legendHeight = this.hideLegend ? 0 : this.$refs.legend?.clientHeight ?? 0;
116+
});
117+
},
118+
},
114119
mounted() {
115-
this.$nextTick(() => {
116-
this.legendHeight = this.$refs.legend.offsetHeight;
117-
});
120+
this.updateLegendHeight();
118121
},
119122
};
120123
</script>

0 commit comments

Comments
 (0)