Commit 3bbc4805 authored by Merzough Münker's avatar Merzough Münker
Browse files

fix(form-control): ensure state function execution

parent f0871d72
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -169,7 +169,13 @@ export class RxapFormControl<T = any, E extends object = any, Parent extends obj
  }

  public reset(formState?: OrBoxedValue<T>, options?: ControlEventOptions): void {
    super.reset(formState ?? this.initialState, options);
    const newState = formState ?? this.initialState;

    if (typeof newState === 'function') {
      super.reset((newState as any)(), options);
    } else {
      super.reset(newState, options);
    }
  }

  public setValidators(newValidator: Validator, updateValueAndValidity: boolean = true): void {
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ export interface BoxedValue<T> {
  disabled?: boolean;
}

export type OrBoxedValue<T> = T | BoxedValue<T>;
export type OrBoxedValue<T> = T | BoxedValue<T> | (() => T);

type ArrayType<T> = T extends Array<infer R> ? R : any;