) : (
{
setValue('paymentMethod', value);
}}
>
{methods.map((method: PaymentMethod) => {
const isSelected =
selectedPaymentMethod === method.code;
const component = getPaymentComponent(method.code);
return (
// Whole-box click selects (Base UI radios only
// react to pointer events on their [role="radio"]
// element, so the box needs its own handler). The
// guard skips the radio itself (double-fire) and
// any control inside the embedded payment form.
{
if (
(e.target as HTMLElement).closest(
'input, button, a, select, textarea, iframe, [role="radio"]'
)
) {
return;
}
if (!isSelected) {
setValue('paymentMethod', method.code);
}
}}
className={`cursor-pointer ${
isSelected ? 'border-primary' : ''
}`}
>
{/* The row is a
{/* Not clamped: a method's form may hold more
than ItemDescription's two lines (#1175). */}
{component?.formRenderer && isSelected && (
{renderComponent(component.formRenderer, {
isSelected
})}
)}
);
})}
)}
{formState.errors.paymentMethod && (
{formState.errors.paymentMethod?.message?.toString() ||
_('Please select a payment method')}