Fix stale address coordinates after clearing autofill (#20264)

Closes #20082
This commit is contained in:
Abdul Rahman
2026-05-05 20:13:51 +05:30
committed by GitHub
parent e89b12488c
commit 3d60e6dbfc
5 changed files with 75 additions and 3 deletions
@@ -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 (
@@ -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;
@@ -48,6 +48,8 @@ export const computeEmptyDraftValue = <FieldValue>({
addressState: '',
addressCountry: '',
addressPostcode: '',
addressLat: null,
addressLng: null,
} as unknown as FieldInputDraftValue<FieldValue>;
}