From 1407218280a189ae9d3497ebf4c560423ebcc8c9 Mon Sep 17 00:00:00 2001 From: Aodhagan Murphy Date: Tue, 7 Nov 2023 12:09:36 +0000 Subject: [PATCH 1/3] fix: falling back to undefined if lon and lat are null [] --- packages/location/src/LocationEditor.tsx | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/location/src/LocationEditor.tsx b/packages/location/src/LocationEditor.tsx index c2025dc65..e51ece747 100644 --- a/packages/location/src/LocationEditor.tsx +++ b/packages/location/src/LocationEditor.tsx @@ -66,12 +66,13 @@ export class LocationEditor extends React.Component< super(props); this.state = { - localValue: props.value - ? { - lng: props.value.lon, - lat: props.value.lat, - } - : undefined, + localValue: + props?.value?.lon && props?.value.lat + ? { + lng: props.value.lon, + lat: props.value.lat, + } + : undefined, mapsObject: null, }; } @@ -168,16 +169,18 @@ export function LocationEditorConnected(props: LocationEditorConnectedProps) { > {({ value, disabled, setValue, externalReset }) => { return ( - + <> + + ); }} From f2ca07e12ea57cdaae413195dee3ae0040150a70 Mon Sep 17 00:00:00 2001 From: Aodhagan Murphy Date: Tue, 7 Nov 2023 12:13:01 +0000 Subject: [PATCH 2/3] fix: adjusting location logic [] --- packages/location/src/LocationEditor.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/location/src/LocationEditor.tsx b/packages/location/src/LocationEditor.tsx index e51ece747..e768c1ee2 100644 --- a/packages/location/src/LocationEditor.tsx +++ b/packages/location/src/LocationEditor.tsx @@ -67,10 +67,12 @@ export class LocationEditor extends React.Component< this.state = { localValue: - props?.value?.lon && props?.value.lat + // if we have only the lon or lat set, we set the other to 0. + // if both are not set, we set localValue to undefined. + props?.value?.lon || props?.value?.lat ? { - lng: props.value.lon, - lat: props.value.lat, + lng: props.value.lon ?? 0, + lat: props.value.lat ?? 0, } : undefined, mapsObject: null, From d7446264182c3c9288ba886ac41ae909f8d90178 Mon Sep 17 00:00:00 2001 From: Aodhagan Murphy Date: Tue, 7 Nov 2023 12:22:50 +0000 Subject: [PATCH 3/3] fix: removing fragment [] --- packages/location/src/LocationEditor.tsx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/location/src/LocationEditor.tsx b/packages/location/src/LocationEditor.tsx index e768c1ee2..b91a1118e 100644 --- a/packages/location/src/LocationEditor.tsx +++ b/packages/location/src/LocationEditor.tsx @@ -171,18 +171,16 @@ export function LocationEditorConnected(props: LocationEditorConnectedProps) { > {({ value, disabled, setValue, externalReset }) => { return ( - <> - - + ); }}