From fef17476c8a5164abb24efd135a0af8b2af52b24 Mon Sep 17 00:00:00 2001 From: Michael Rogowski Date: Mon, 17 Dec 2018 15:15:32 -0500 Subject: [PATCH] Fix undefined error when selecting a product without an image (https://github.com/woocommerce/woocommerce-blocks/pull/254) prior to this commit, an 'individual product' block would produce an error if associated with a product with no image. --- .../assets/js/legacy/views/specific-select.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce-blocks/assets/js/legacy/views/specific-select.jsx b/plugins/woocommerce-blocks/assets/js/legacy/views/specific-select.jsx index 50463e5221a..23d542fe763 100644 --- a/plugins/woocommerce-blocks/assets/js/legacy/views/specific-select.jsx +++ b/plugins/woocommerce-blocks/assets/js/legacy/views/specific-select.jsx @@ -348,13 +348,15 @@ class ProductSpecificSearchResultsDropdownElement extends Component { render() { const product = this.props.product; const icon = this.props.selected ? : null; + const productImage = product.images.length !== 0 ? + ({) : null; /* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */ /* reason: This interface will be deprecated, the new component is accessible. */ return (
- + { productImage } { product.name } { icon }
@@ -458,11 +460,13 @@ class ProductSpecificSelectedProducts extends Component { } const productData = PRODUCT_DATA[ productId ]; + const productImage = productData.images.length !== 0 ? + ({) : null; productElements.push(
  • - + { productImage } { productData.name }