From 9b79d71ac7508c1ffc89b596030194eff46d242f Mon Sep 17 00:00:00 2001 From: Jacobo de Vera Date: Mon, 26 Aug 2024 23:38:45 +0100 Subject: [PATCH] Fix: Check explicitly for arrays and strings on size formatter "length" in data was a brittle check that failed for scalar values. --- src/widgets/customapi/component.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/customapi/component.jsx b/src/widgets/customapi/component.jsx index 6acccd3ea..282cb0a5f 100644 --- a/src/widgets/customapi/component.jsx +++ b/src/widgets/customapi/component.jsx @@ -5,7 +5,7 @@ import Block from "components/services/widget/block"; import useWidgetAPI from "utils/proxy/use-widget-api"; function getLength(data) { - if ("length" in data) { + if (Array.isArray(data) || typeof data === "string") { return data.length; } else if (typeof data === "object" && data !== null) { return Object.keys(data).length;