Skip to content

Commit

Permalink
refactor: don't use shared global form for Fields
Browse files Browse the repository at this point in the history
If the user uses the Fields component more than once, inputs with the same names could be rendered. If these inputs aren't wrapped in a form, they will share the same global form state and trigger errors.
  • Loading branch information
chrisvxd committed Dec 11, 2023
1 parent 22f053f commit 22546d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/core/components/Puck/components/Fields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export const Fields = () => {
const rootProps = data.root.props || data.root;

return (
<div className={getClassName()}>
<form
className={getClassName()}
onSubmit={(e) => {
e.preventDefault();
}}
>
<div>
{Object.keys(fields).map((fieldName) => {
const field = fields[fieldName];
Expand Down Expand Up @@ -163,6 +168,6 @@ export const Fields = () => {
<ClipLoader />
</div>
)}
</div>
</form>
);
};

0 comments on commit 22546d8

Please sign in to comment.