From 050601232ac4f424e9d3ba6b711f3ada4afe253b Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 3 Sep 2024 17:59:03 +0200 Subject: [PATCH] fix(layout): prevent negative width/height values (#10616) --- packages/core/ui/core/view/view-helper/index.ios.ts | 11 ++++++++--- .../ui/core/view/view-helper/view-helper-common.ts | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/core/ui/core/view/view-helper/index.ios.ts b/packages/core/ui/core/view/view-helper/index.ios.ts index 0ce7c56623..a5057372f0 100644 --- a/packages/core/ui/core/view/view-helper/index.ios.ts +++ b/packages/core/ui/core/view/view-helper/index.ios.ts @@ -261,9 +261,14 @@ export class IOSHelper { const left = layout.toDeviceIndependentPixels(position.left + insets.left); const top = layout.toDeviceIndependentPixels(position.top + insets.top); - const width = layout.toDeviceIndependentPixels(position.right - position.left - insets.left - insets.right); - const height = layout.toDeviceIndependentPixels(position.bottom - position.top - insets.top - insets.bottom); - + let width = layout.toDeviceIndependentPixels(position.right - position.left - insets.left - insets.right); + let height = layout.toDeviceIndependentPixels(position.bottom - position.top - insets.top - insets.bottom); + if (width < 0) { + width = 0; + } + if (height < 0) { + height = 0; + } return CGRectMake(left, top, width, height); } diff --git a/packages/core/ui/core/view/view-helper/view-helper-common.ts b/packages/core/ui/core/view/view-helper/view-helper-common.ts index ae3ad96798..14b638f7df 100644 --- a/packages/core/ui/core/view/view-helper/view-helper-common.ts +++ b/packages/core/ui/core/view/view-helper/view-helper-common.ts @@ -82,6 +82,9 @@ export class ViewHelper { default: childTop = top + effectiveMarginTop; childHeight = bottom - top - (effectiveMarginTop + effectiveMarginBottom); + if (childHeight < 0) { + childHeight = 0; + } break; } @@ -112,6 +115,9 @@ export class ViewHelper { default: childLeft = left + effectiveMarginLeft; childWidth = right - left - (effectiveMarginLeft + effectiveMarginRight); + if (childWidth < 0) { + childWidth = 0; + } break; }