react-hook-form 7.56.3 → 7.56.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1305,8 +1305,6 @@ function createFormControl(props = {}) {
1305
1305
  array: createSubject(),
1306
1306
  state: createSubject(),
1307
1307
  };
1308
- const validationModeBeforeSubmit = getValidationModes(_options.mode);
1309
- const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
1310
1308
  const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
1311
1309
  const debounce = (callback) => (wait) => {
1312
1310
  clearTimeout(timer);
@@ -1577,13 +1575,17 @@ function createFormControl(props = {}) {
1577
1575
  }
1578
1576
  else if (fieldReference.refs) {
1579
1577
  if (isCheckBoxInput(fieldReference.ref)) {
1580
- fieldReference.refs.length > 1
1581
- ? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
1582
- (checkboxRef.checked = Array.isArray(fieldValue)
1583
- ? !!fieldValue.find((data) => data === checkboxRef.value)
1584
- : fieldValue === checkboxRef.value))
1585
- : fieldReference.refs[0] &&
1586
- (fieldReference.refs[0].checked = !!fieldValue);
1578
+ fieldReference.refs.forEach((checkboxRef) => {
1579
+ if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
1580
+ if (Array.isArray(fieldValue)) {
1581
+ checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1582
+ }
1583
+ else {
1584
+ checkboxRef.checked =
1585
+ fieldValue === checkboxRef.value || !!fieldValue;
1586
+ }
1587
+ }
1588
+ });
1587
1589
  }
1588
1590
  else {
1589
1591
  fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
@@ -1609,6 +1611,9 @@ function createFormControl(props = {}) {
1609
1611
  };
1610
1612
  const setValues = (name, value, options) => {
1611
1613
  for (const fieldKey in value) {
1614
+ if (!value.hasOwnProperty(fieldKey)) {
1615
+ return;
1616
+ }
1612
1617
  const fieldValue = value[fieldKey];
1613
1618
  const fieldName = `${name}.${fieldKey}`;
1614
1619
  const field = get(_fields, fieldName);
@@ -1665,6 +1670,8 @@ function createFormControl(props = {}) {
1665
1670
  (isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
1666
1671
  deepEqual(fieldValue, get(_formValues, name, fieldValue));
1667
1672
  };
1673
+ const validationModeBeforeSubmit = getValidationModes(_options.mode);
1674
+ const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
1668
1675
  if (field) {
1669
1676
  let error;
1670
1677
  let isValid;