Errors not shown when tabbing to inputs outside this library
Opened this issue · 0 comments
cipater commented
What's the rational for this check?
react-payment-inputs/src/usePaymentInputs.js
Lines 57 to 61 in 687df51
Because the net effect is that validation errors aren't displayed when tabbing to other fields within the form that aren't part of this library. Is that intentional?
Since cardNumber
isn't valid or invalid based on the validity of the other fields, why not show errors (if any) as soon as it looses focus?
Or, at a minimum to maintain a similar behavior, how about just checking to see if library fields are active?
if (
document.activeElement !== cardNumberField.current &&
document.activeElement !== expiryDateField.current &&
document.activeElement !== cvcField.current &&
document.activeElement !== zipField.current
) {
setIsTouched(true);
} else if (value === false) {
setIsTouched(false);
}