Skip to content

Commit

Permalink
NEXT-37512 - Fix cms product slider offsetWidth error
Browse files Browse the repository at this point in the history
  • Loading branch information
lacknere authored and marcelbrode committed Aug 2, 2024
1 parent 13be071 commit 56829b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Fix cms product slider offsetWidth error
issue: NEXT-00000
author: Elias Lackner
author_email: [email protected]
author_github: @lacknere
---
# Administration
* Changed method `setSliderRowLimit` in `sw-cms-el-product-slider` component to check undefined `productHolder` ref when reading `offsetWidth`.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ export default {
},

setSliderRowLimit() {
if (this.currentDeviceView === 'mobile' || this.$refs.productHolder.offsetWidth < 500) {
const boxWidth = this.$refs.productHolder?.offsetWidth;

if (boxWidth === undefined) {
return;
}

if (this.currentDeviceView === 'mobile' || boxWidth < 500) {
this.sliderBoxLimit = 1;
return;
}
Expand All @@ -122,7 +128,6 @@ export default {

// Subtract to fake look in storefront which has more width
const fakeLookWidth = 100;
const boxWidth = this.$refs.productHolder.offsetWidth;
const elGap = 32;
let elWidth = parseInt(this.element.config.elMinWidth.value.replace('px', ''), 10);

Expand Down

0 comments on commit 56829b4

Please sign in to comment.