react-hook-form 7.49.0 → 7.49.2

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.
@@ -407,9 +407,8 @@ function useController(props) {
407
407
  const _registerProps = React.useRef(control.register(name, {
408
408
  ...props.rules,
409
409
  value,
410
- disabled: props.disabled,
410
+ ...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),
411
411
  }));
412
- _registerProps.current = control.register(name, props.rules);
413
412
  React.useEffect(() => {
414
413
  const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
415
414
  const updateMounted = (name, value) => {
@@ -1657,15 +1656,16 @@ function createFormControl(props = {}, flushRootRender) {
1657
1656
  const output = {
1658
1657
  name,
1659
1658
  };
1659
+ const disabledField = !!(get(_fields, name) && get(_fields, name)._f.disabled);
1660
1660
  if (!isBlurEvent || shouldDirty) {
1661
1661
  if (_proxyFormState.isDirty) {
1662
1662
  isPreviousDirty = _formState.isDirty;
1663
1663
  _formState.isDirty = output.isDirty = _getDirty();
1664
1664
  shouldUpdateField = isPreviousDirty !== output.isDirty;
1665
1665
  }
1666
- const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);
1667
- isPreviousDirty = get(_formState.dirtyFields, name);
1668
- isCurrentFieldPristine
1666
+ const isCurrentFieldPristine = disabledField || deepEqual(get(_defaultValues, name), fieldValue);
1667
+ isPreviousDirty = !!(!disabledField && get(_formState.dirtyFields, name));
1668
+ isCurrentFieldPristine || disabledField
1669
1669
  ? unset(_formState.dirtyFields, name)
1670
1670
  : set(_formState.dirtyFields, name, true);
1671
1671
  output.dirtyFields = _formState.dirtyFields;
@@ -2093,6 +2093,7 @@ function createFormControl(props = {}, flushRootRender) {
2093
2093
  field,
2094
2094
  disabled: options.disabled,
2095
2095
  name,
2096
+ value: options.value,
2096
2097
  });
2097
2098
  }
2098
2099
  else {