From 64f6481fd6438bc083ebd8bf1f42be5f87c1b32c Mon Sep 17 00:00:00 2001 From: Bao Nguyen Date: Fri, 14 Aug 2026 09:06:36 +0700 Subject: [PATCH] fix(Camera): allow partial padding on the root padding prop `CameraStop.padding` was typed as `CameraPadding`, which requires all four edges, so `padding={{ paddingBottom: 10 }}` failed to compile with TS2739 even though the runtime already supports partial padding: `buildNativeStop` reads every edge individually and only forwards the ones that are defined. Widen the prop to `Partial`, matching `followPadding` and `CameraBoundsWithPadding` in the same file. The exported `CameraPadding` type is unchanged, so this is not a breaking change. Fixes #3599 --- docs/Camera.md | 11 +++-------- docs/docs.json | 40 ++++----------------------------------- src/components/Camera.tsx | 4 ++-- 3 files changed, 9 insertions(+), 46 deletions(-) diff --git a/docs/Camera.md b/docs/Camera.md index 9408680a54..6308f4e09b 100644 --- a/docs/Camera.md +++ b/docs/Camera.md @@ -90,14 +90,9 @@ The zoom level of the map. ### padding ```tsx -type Padding = { - paddingLeft: number; /* Left padding in points */ - paddingRight: number; /* Right padding in points */ - paddingTop: number; /* Top padding in points */ - paddingBottom: number; /* Bottom padding in points */ -} +Partial ``` -The viewport padding in points. +The viewport padding in points. Individual edges may be omitted. @@ -218,7 +213,7 @@ compatibility; the root `padding` prop should be used instead. */ heading: number; /* Heading (bearing, orientation) of the map, measured in degrees clockwise from true north. */ pitch: number; /* The pitch toward the horizon measured in degrees, with 0 degrees resulting in a top-down view for a two-dimensional map. */ zoomLevel: number; /* The zoom level of the map. */ - padding: signature; /* The viewport padding in points. */ + padding: Partial; /* The viewport padding in points. Individual edges may be omitted. */ animationDuration: number; /* The duration the map takes to animate to a new configuration. */ animationMode: 'flyTo' \| 'easeTo' \| 'linearTo' \| 'moveTo' \| 'none'; /* The easing or path the camera uses to animate to a new configuration. */ } diff --git a/docs/docs.json b/docs/docs.json index e27e8cc675..81749326f2 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -793,41 +793,9 @@ { "name": "padding", "required": false, - "type": { - "name": "shape", - "value": [ - { - "name": "paddingLeft", - "required": true, - "type": "number", - "default": "none", - "description": "Left padding in points" - }, - { - "name": "paddingRight", - "required": true, - "type": "number", - "default": "none", - "description": "Right padding in points" - }, - { - "name": "paddingTop", - "required": true, - "type": "number", - "default": "none", - "description": "Top padding in points" - }, - { - "name": "paddingBottom", - "required": true, - "type": "number", - "default": "none", - "description": "Bottom padding in points" - } - ] - }, + "type": "Partial", "default": "none", - "description": "The viewport padding in points." + "description": "The viewport padding in points. Individual edges may be omitted." }, { "name": "animationDuration", @@ -975,9 +943,9 @@ { "name": "padding", "required": false, - "type": "signature", + "type": "Partial", "default": "none", - "description": "The viewport padding in points." + "description": "The viewport padding in points. Individual edges may be omitted." }, { "name": "animationDuration", diff --git a/src/components/Camera.tsx b/src/components/Camera.tsx index c8e61a0d9e..c7bc631262 100644 --- a/src/components/Camera.tsx +++ b/src/components/Camera.tsx @@ -147,8 +147,8 @@ export type CameraStop = { pitch?: number; /** The zoom level of the map. */ zoomLevel?: number; - /** The viewport padding in points. */ - padding?: CameraPadding; + /** The viewport padding in points. Individual edges may be omitted. */ + padding?: Partial; /** The duration the map takes to animate to a new configuration. */ animationDuration?: number; /** The easing or path the camera uses to animate to a new configuration. */