Fix stale address coordinates after clearing autofill (#20264)
Closes #20082
This commit is contained in:
+2
-1
@@ -7,6 +7,7 @@ import { type FieldAddressDraftValue } from '@/object-record/record-field/ui/typ
|
||||
import { type FieldAddressValue } from '@/object-record/record-field/ui/types/FieldMetadata';
|
||||
import { InputLabel } from '@/ui/input/components/InputLabel';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { normalizeAddressFieldValueForPersist } from '~/utils/normalize-address-field-value-for-persist';
|
||||
|
||||
type FormAddressFieldInputProps = {
|
||||
label?: string;
|
||||
@@ -36,7 +37,7 @@ export const FormAddressFieldInput = ({
|
||||
addressLng: defaultValue?.addressLng ?? null,
|
||||
[field]: updatedAddressPart,
|
||||
};
|
||||
onChange(updatedAddress);
|
||||
onChange(normalizeAddressFieldValueForPersist(updatedAddress));
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
+3
-2
@@ -8,6 +8,7 @@ import { FieldInputEventContext } from '@/object-record/record-field/ui/contexts
|
||||
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
||||
import { useContext } from 'react';
|
||||
import { castAsNumberOrNull } from '~/utils/cast-as-number-or-null';
|
||||
import { normalizeAddressFieldValueForPersist } from '~/utils/normalize-address-field-value-for-persist';
|
||||
|
||||
export const AddressFieldInput = () => {
|
||||
const { draftValue, setDraftValue, fieldDefinition } = useAddressField();
|
||||
@@ -19,7 +20,7 @@ export const AddressFieldInput = () => {
|
||||
const convertToAddress = (
|
||||
newAddress: FieldAddressDraftValue | undefined,
|
||||
): FieldAddressDraftValue => {
|
||||
return {
|
||||
return normalizeAddressFieldValueForPersist({
|
||||
addressStreet1: newAddress?.addressStreet1 ?? '',
|
||||
addressStreet2: newAddress?.addressStreet2 ?? null,
|
||||
addressCity: newAddress?.addressCity ?? null,
|
||||
@@ -28,7 +29,7 @@ export const AddressFieldInput = () => {
|
||||
addressPostcode: newAddress?.addressPostcode ?? null,
|
||||
addressLat: castAsNumberOrNull(newAddress?.addressLat),
|
||||
addressLng: castAsNumberOrNull(newAddress?.addressLng),
|
||||
};
|
||||
});
|
||||
};
|
||||
const settings = fieldDefinition.metadata.settings;
|
||||
|
||||
|
||||
+2
@@ -48,6 +48,8 @@ export const computeEmptyDraftValue = <FieldValue>({
|
||||
addressState: '',
|
||||
addressCountry: '',
|
||||
addressPostcode: '',
|
||||
addressLat: null,
|
||||
addressLng: null,
|
||||
} as unknown as FieldInputDraftValue<FieldValue>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user