From db2bdf3246815845cf6cc23d91d3ca6313c727cf Mon Sep 17 00:00:00 2001 From: Katrin Yordanova Date: Wed, 3 Jan 2024 14:19:05 +0200 Subject: [PATCH] Properly fix mapObject undefined error in CMap when switching to another page --- lib/vue/src/components/map/CMap.vue | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/vue/src/components/map/CMap.vue b/lib/vue/src/components/map/CMap.vue index 27788983e..8b68d4918 100644 --- a/lib/vue/src/components/map/CMap.vue +++ b/lib/vue/src/components/map/CMap.vue @@ -282,16 +282,14 @@ export default { }, onBoundsUpdate (value) { - if (this.$refs.map) { - setTimeout(() => { - this.$refs.map.mapObject.invalidateSize() - }, 100) - - value = value || this.$refs.map.mapObject.getBounds() - - this.$emit('on-bounds-update', value) - } - } + this.$nextTick(() => { + this.$refs.map.mapObject.invalidateSize() + }) + + value = value || this.$refs.map.mapObject.getBounds() + + this.$emit('on-bounds-update', value) + }, }, }