From 9ecf899a865a606aa19de8951f78d3a1bd8fc46a Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 1 Jun 2022 16:36:26 -0300 Subject: [PATCH] Checks if maxItemsNumber is undefined. --- .../gutenberg-blocks/blocks/dynamic-items-list/deprecated.js | 3 +++ src/views/gutenberg-blocks/blocks/dynamic-items-list/edit.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/gutenberg-blocks/blocks/dynamic-items-list/deprecated.js b/src/views/gutenberg-blocks/blocks/dynamic-items-list/deprecated.js index 1724c1996..3b560cfd0 100644 --- a/src/views/gutenberg-blocks/blocks/dynamic-items-list/deprecated.js +++ b/src/views/gutenberg-blocks/blocks/dynamic-items-list/deprecated.js @@ -8,6 +8,9 @@ export default [ attributes.imageSize = 'tainacan-medium'; else attributes.imageSize = 'tainacan-medium-full'; + + if ( isNaN(attributes.maxItemsNumber) ) + attributes.maxItemsNumber = 12; return attributes; }, diff --git a/src/views/gutenberg-blocks/blocks/dynamic-items-list/edit.js b/src/views/gutenberg-blocks/blocks/dynamic-items-list/edit.js index b3333f100..6d1324967 100644 --- a/src/views/gutenberg-blocks/blocks/dynamic-items-list/edit.js +++ b/src/views/gutenberg-blocks/blocks/dynamic-items-list/edit.js @@ -281,7 +281,7 @@ export default function({ attributes, setAttributes, className, isSelected, clie if (maxItemsNumber != undefined && maxItemsNumber > 0) queryObject.perpage = maxItemsNumber; else if (queryObject.perpage != undefined && queryObject.perpage > 0) - setAttributes({ maxItemsNumber: queryObject.perpage }); + setAttributes({ maxItemsNumber: Number(queryObject.perpage) }); else { queryObject.perpage = 12; setAttributes({ maxItemsNumber: 12 });