diff --git a/Sources/PediFoods/Views/Main/CheckoutView.swift b/Sources/PediFoods/Views/Main/CheckoutView.swift index fbbe7f6..0c692bd 100644 --- a/Sources/PediFoods/Views/Main/CheckoutView.swift +++ b/Sources/PediFoods/Views/Main/CheckoutView.swift @@ -558,12 +558,19 @@ struct CheckoutView: View { } private var customerAddressName: String { - let label = (selectedCustomerAddress?.label ?? "").trimmingCharacters(in: .whitespacesAndNewlines) - if label.isEmpty == false { return label } - + // appState.address.display is set directly, synchronously, the + // moment the user picks an address (AddressesView.selectAddress) — + // it's live. selectedCustomerAddress is resolved later via an async + // matching cascade against the address book and can briefly (or, + // if matching goes wrong, persistently) lag behind or resolve to + // the wrong entry. Prefer the live value; the async one is only a + // fallback for when nothing's been picked yet this session. let displayLabel = appState.address.display.trimmingCharacters(in: .whitespacesAndNewlines) if displayLabel.isEmpty == false, displayLabel != "Defina seu endereco" { return displayLabel } + let label = (selectedCustomerAddress?.label ?? "").trimmingCharacters(in: .whitespacesAndNewlines) + if label.isEmpty == false { return label } + return "Endereço" }