Skip to content

Commit

Permalink
fix(context): lock
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Apr 2, 2024
1 parent 47db109 commit 1dfdb4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/context/Context.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { asyncContext } from "./dist/index.js";
export interface Props {
[key: string]: any
contextName?: string
lock?: string
}
const contextName = Astro.props.contextName;
const {contextName, lock, ...props} = Astro.props;
delete Astro.props.lock;
delete Astro.props.contextName;
const htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: contextName});
const htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: contextName, lock, context: props});
---
<Fragment set:html={htmlSolt} />
2 changes: 1 addition & 1 deletion packages/forms/src/components/WebForms.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const context = {
},
};
const htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: '@astro-utils/forms', context});
const htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: '@astro-utils/forms', context, lock: "webForms"});
const {webFormsSettings, tempValues, viewStates, ...props} = context;
if (webFormsSettings.haveFileUpload) {
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/components/form/BindForm.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const context = {executeAfter: [], method: Astro.request.method, bind, tempBindV
const viewState = new ViewStateManager(bind, context.elementsState, Astro, viewStates.counter++);
await viewState.loadState();
let htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: '@astro-utils/forms', context});
let htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: '@astro-utils/forms', context, lock: "bindForm"});
bind.__finishFormValidation();
for (const func of context.executeAfter) {
await (func as any)();
Expand All @@ -25,7 +25,7 @@ for (const func of context.executeAfter) {
if (context.method == 'POST') {
context.method = 'GET';
context.tempBindValues = {};
htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: '@astro-utils/forms', context});
htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: '@astro-utils/forms', context, lock: "bindForm"});
}
---

Expand Down

0 comments on commit 1dfdb4d

Please sign in to comment.