From c1c497da578dd7168dd15ad1cf22f33af2003aad Mon Sep 17 00:00:00 2001 From: ido Date: Wed, 7 Aug 2024 20:50:54 +0300 Subject: [PATCH] fix(state): disable state --- .../forms/src/components-control/form-utils/view-state.ts | 4 ++-- packages/forms/src/components/form/BindForm.astro | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/forms/src/components-control/form-utils/view-state.ts b/packages/forms/src/components-control/form-utils/view-state.ts index bcadca0..da67144 100644 --- a/packages/forms/src/components-control/form-utils/view-state.ts +++ b/packages/forms/src/components-control/form-utils/view-state.ts @@ -85,12 +85,12 @@ export default class ViewStateManager { } public async createViewState(): Promise { - const data = { + const data = this.useState ?{ bind: this.omitProps ? omitProps(this._bind.__getState(), this.omitProps): getSomeProps(this._bind.__getState(), this.stateProp), elements: this._elementsState - }; + }: {}; const stringify = superjson.stringify(data); const compress = await snappy.compress(stringify, {}); diff --git a/packages/forms/src/components/form/BindForm.astro b/packages/forms/src/components/form/BindForm.astro index 14654a2..a0e4ee5 100644 --- a/packages/forms/src/components/form/BindForm.astro +++ b/packages/forms/src/components/form/BindForm.astro @@ -9,9 +9,10 @@ export interface Props { state?: boolean | string[]; omitState?: string[]; defaultSubmitClick?: string | false; + key?: string } -const { lastRender: parantLastRender, bindId: parantbindId = '' } = getContext(Astro, '@astro-utils/forms'); +const { lastRender: parantLastRender, key = '', bindId: parantbindId = '' } = getContext(Astro, '@astro-utils/forms'); if (parantLastRender === false) { return; } @@ -27,7 +28,7 @@ const context = { onSubmitClickGlobal: defaultSubmitClick, buttonIds: [] as [string, string | null, boolean][], settings: { showValidationErrors: false }, - bindId: Astro.locals.__formsInternalUtils.bindFormCounter++, + bindId: key + (Astro.locals.__formsInternalUtils.bindFormCounter++), lastRender: false, newState: false, }; @@ -80,6 +81,5 @@ resetContext(); context.lastRender = true; const htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, { name: '@astro-utils/forms', context, lock: 'bindForm' + parantbindId }); --- -