Repository: react-hook-form/react-hook-form
File: src/logic/createFormControl.ts (TypeScript)

Code before:
        ? _formState.dirtyFields
        : ((keepStateOptions.keepDefaultValues && formValues
            ? Object.entries(formValues).reduce(
                (previous, [key, value]) => ({
                  ...previous,
                  [key]: value !== get(_defaultValues, key),
                }),
                {},
              )
            : {}) as FieldNamesMarkedBoolean<TFieldValues>),
      touchedFields: keepStateOptions.keepTouched
        ? _formState.touchedFields
        : ({} as FieldNamesMarkedBoolean<TFieldValues>),
      errors: keepStateOptions.keepErrors
        ? _formState.errors
        : ({} as FieldErrors<TFieldValues>),
      isSubmitting: false,
      isSubmitSuccessful: false,
    });
  };

  const setFocus: UseFormSetFocus<TFieldValues> = (name, options = {}) => {
    const field = get(_fields, name)._f;
    options.shouldSelect
      ? (field.ref.select ? field.ref : field.refs[0]).select()
      : (field.ref.focus ? field.ref : field.refs[0]).focus();
  };

  return {
    control: {
      register,
      unregister,
      getFieldState,
      _executeSchema,
      _getWatch,
      _getDirty,
      _updateValid,
      _removeUnmounted,
      _updateFieldArray,
      _getFieldArray,
      _subjects,
      _proxyFormState,
      get _fields() {
        return _fields;
      },
      get _formValues() {
        return _formValues;
      },
      get _stateFlags() {
        return _stateFlags;
      },

Review comment (suggestion):
```suggestion
    const field = field.ref.select ? field.ref : field.refs[0];
    options.shouldSelect ? field.select() : field.focus();
```
It may use fewer bytes.

Code after:
        ? _formState.dirtyFields
        : ((keepStateOptions.keepDefaultValues && formValues
            ? Object.entries(formValues).reduce(
                (previous, [key, value]) => ({
                  ...previous,
                  [key]: value !== get(_defaultValues, key),
                }),
                {},
              )
            : {}) as FieldNamesMarkedBoolean<TFieldValues>),
      touchedFields: keepStateOptions.keepTouched
        ? _formState.touchedFields
        : ({} as FieldNamesMarkedBoolean<TFieldValues>),
      errors: keepStateOptions.keepErrors
        ? _formState.errors
        : ({} as FieldErrors<TFieldValues>),
      isSubmitting: false,
      isSubmitSuccessful: false,
    });
  };

  const setFocus: UseFormSetFocus<TFieldValues> = (name, options = {}) => {
    const field = get(_fields, name)._f;
    const fieldRef = field.refs ? field.refs[0] : field.ref;
    options.shouldSelect ? fieldRef.select() : fieldRef.focus();
  };

  return {
    control: {
      register,
      unregister,
      getFieldState,
      _executeSchema,
      _getWatch,
      _getDirty,
      _updateValid,
      _removeUnmounted,
      _updateFieldArray,
      _getFieldArray,
      _subjects,
      _proxyFormState,
      get _fields() {
        return _fields;
      },
      get _formValues() {
        return _formValues;
      },
      get _stateFlags() {
        return _stateFlags;
      },
      set _stateFlags(value) {