Fix: Check explicitly for arrays and strings on size formatter

"length" in data was a brittle check that failed for scalar values.
This commit is contained in:
Jacobo de Vera
2024-08-26 23:38:45 +01:00
parent 2a94c465bd
commit 9b79d71ac7

View File

@@ -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;