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:
parent
2a94c465bd
commit
9b79d71ac7
@ -5,7 +5,7 @@ import Block from "components/services/widget/block";
|
|||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
function getLength(data) {
|
function getLength(data) {
|
||||||
if ("length" in data) {
|
if (Array.isArray(data) || typeof data === "string") {
|
||||||
return data.length;
|
return data.length;
|
||||||
} else if (typeof data === "object" && data !== null) {
|
} else if (typeof data === "object" && data !== null) {
|
||||||
return Object.keys(data).length;
|
return Object.keys(data).length;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user