medipass/react-payment-inputs

Errors not shown when tabbing to inputs outside this library

Opened this issue · 0 comments

What's the rational for this check?

if (document.activeElement.tagName !== 'INPUT') {
setIsTouched(true);
} else if (value === false) {
setIsTouched(false);
}

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);
}