From b463c3050c5938874afa479908535df57910488f Mon Sep 17 00:00:00 2001 From: Eric NGUYEN Date: Fri, 30 Sep 2022 11:32:49 +0200 Subject: [PATCH] Fix 0 dimension showing in children dimension --- src/Components/SVG/Elements/DimensionLayer.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Components/SVG/Elements/DimensionLayer.tsx b/src/Components/SVG/Elements/DimensionLayer.tsx index 19f3146..d4da524 100644 --- a/src/Components/SVG/Elements/DimensionLayer.tsx +++ b/src/Components/SVG/Elements/DimensionLayer.tsx @@ -96,7 +96,7 @@ function Dimensions({ root, scale }: IDimensionLayerProps): React.ReactNode[] { ); } - if (SHOW_CHILDREN_DIMENSIONS && container.properties.showChildrenDimensions.length > 0 && container.children.length > 1) { + if (SHOW_CHILDREN_DIMENSIONS && container.properties.showChildrenDimensions.length > 0) { ActionByPosition( dimMapped, container.properties.showChildrenDimensions, @@ -154,6 +154,11 @@ function AddHorizontalChildrenDimension( } } + if (xChildrenStart === xChildrenEnd) { + // do not show an empty dimension + return; + } + const textChildren = (xChildrenEnd - xChildrenStart) .toFixed(2) .toString(); @@ -197,6 +202,11 @@ function AddVerticalChildrenDimension( } } + if (yChildrenStart === yChildrenEnd) { + // do not show an empty dimension + return; + } + const textChildren = (yChildrenEnd - yChildrenStart) .toFixed(2) .toString();