diff --git a/app/checkout/components/CheckoutContent.tsx b/app/checkout/components/CheckoutContent.tsx index 4121cbf..8b94900 100644 --- a/app/checkout/components/CheckoutContent.tsx +++ b/app/checkout/components/CheckoutContent.tsx @@ -354,7 +354,8 @@ export function CheckoutContent({ // wherever vatExemptPreview/exemptTotalsPreview are computed below — a // validated German VAT ID never zero-rates a domestic sale). async function handleVatIdBlur(e: React.FocusEvent) { - const value = e.target.value; + const input = e.target; + const value = input.value; const formatError = validateVatIdFormat(value); setFieldError("vatId", formatError); if (!value.trim() || formatError) { @@ -374,6 +375,14 @@ export function CheckoutContent({ return; } setVatIdViesStatus(data.valid ? "valid" : "invalid"); + // Re-focus + select the whole value on an unconfirmed VAT ID — the + // customer almost certainly needs to retype it (a typo, or the + // wrong id entirely), so the next keystroke should just replace it + // outright rather than requiring a manual select-all first. + if (!data.valid) { + input.focus(); + input.select(); + } } catch { setVatIdViesStatus("unavailable"); } @@ -732,7 +741,9 @@ export function CheckoutContent({ {isExemptionEligibleCountry(buyerDestinationCountry) ? " — Lieferung wird steuerfrei berechnet." : "."} )} - {vatIdViesStatus === "invalid" && "USt-IdNr. konnte nicht bestätigt werden."} + {vatIdViesStatus === "invalid" && ( + USt-IdNr. konnte nicht bestätigt werden. + )} {vatIdViesStatus === "unavailable" && "USt-IdNr.-Prüfung derzeit nicht möglich."}