Skip to content

Commit

Permalink
fix(defaults): load
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Apr 13, 2024
1 parent b21ddca commit b8d8c31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
9 changes: 3 additions & 6 deletions packages/forms/src/components-control/form-utils/bind-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export class BindForm<BindValues> {

private _plugins: IHTMLFormPlugin[];

constructor(private _defaults?: (BindValues | (() => BindValues | Promise<BindValues>))) {
constructor(private _defaults?: BindValues) {
this.defaults();
this.initializePlugins();
}

Expand All @@ -40,11 +41,7 @@ export class BindForm<BindValues> {
}

async defaults() {
if (typeof this._defaults === 'function') {
Object.assign(this, await (this._defaults as () => BindValues)());
} else if (this._defaults) {
Object.assign(this, this._defaults);
}
Object.assign(this, this._defaults);
}

/**
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/components/form/BindForm.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const haveState = await viewState.loadState();
await bind.on.stateLoaded?.();
if(!haveState){
await bind.defaults();
await bind.on.newState?.();
} else {
await bind.on.pagePostBack?.();
Expand Down

0 comments on commit b8d8c31

Please sign in to comment.