Skip to content

Commit

Permalink
fix: prevent field name collision causing hook render mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Dec 16, 2024
1 parent 9991c07 commit b51954a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/core/components/Puck/components/Fields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,14 @@ export const Fields = () => {
item: selectedItem,
});

const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;

return (
<AutoFieldPrivate
key={`${selectedItem.props.id}_${fieldName}`}
key={id}
field={field}
name={fieldName}
id={`${selectedItem.props.id}_${fieldName}`}
id={id}
readOnly={!edit || readOnly[fieldName]}
value={selectedItem.props[fieldName]}
onChange={onChange}
Expand All @@ -289,12 +291,14 @@ export const Fields = () => {
root: true,
});

const id = `root_${field.type}_${fieldName}`;

return (
<AutoFieldPrivate
key={`page_${fieldName}`}
key={id}
field={field}
name={fieldName}
id={`root_${fieldName}`}
id={id}
readOnly={!edit || readOnly[fieldName]}
value={(rootProps as Record<string, any>)[fieldName]}
onChange={onChange}
Expand Down

0 comments on commit b51954a

Please sign in to comment.