Skip to content

Commit bfd1ece

Browse files
committed
fix(CCarousel): Uncaught TypeError: Cannot read properties of null (reading 'getBoundingClientRect')
1 parent 51ce9d1 commit bfd1ece

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/coreui-vue/src/components/carousel/CCarousel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const CCarousel = defineComponent({
119119
const nextItemWhenVisible = () => {
120120
// Don't call next when the page isn't visible
121121
// or the carousel or its parent isn't visible
122-
if (!document.hidden && isInViewport(carouselRef.value)) {
122+
if (!document.hidden && carouselRef.value && isInViewport(carouselRef.value)) {
123123
handleControlClick('next')
124124
}
125125
}
@@ -142,7 +142,7 @@ const CCarousel = defineComponent({
142142
}
143143

144144
const handleScroll = () => {
145-
if (!document.hidden && isInViewport(carouselRef.value)) {
145+
if (!document.hidden && carouselRef.value && isInViewport(carouselRef.value)) {
146146
visible.value = true
147147
} else {
148148
visible.value = false

0 commit comments

Comments
 (0)