Skip to content

Commit

Permalink
fix(state): disable state
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Aug 7, 2024
1 parent a807223 commit c1c497d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ export default class ViewStateManager {
}

public async createViewState(): Promise<string> {
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, {});
Expand Down
6 changes: 3 additions & 3 deletions packages/forms/src/components/form/BindForm.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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,
};
Expand Down Expand Up @@ -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 });
---

<input type='hidden' name={viewState.filedName} value={await viewState.createViewState()} />
<Fragment set:html={htmlSolt} />

0 comments on commit c1c497d

Please sign in to comment.