Skip to content

Commit

Permalink
fix(object-widget): highlight nested validation errors
Browse files Browse the repository at this point in the history
When building nested controls for fields in an object widget, ensure the
object's ID is passed through as a 'parent' so that errors in nested
fields can be linked to the parent.

This ensures that a validation error on a field within an object will
"bubble up" and show an error on a collapsed object's control in the
editor, helping users to identify where there are validation errors.
  • Loading branch information
domcleal committed Nov 25, 2024
1 parent 022dbe5 commit 73a5de4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/decap-cms-widget-object/src/ObjectControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default class ObjectControl extends React.Component {
isFieldHidden,
locale,
collapsed,
forID,
} = this.props;

if (field.get('widget') === 'hidden') {
Expand All @@ -112,7 +113,7 @@ export default class ObjectControl extends React.Component {
onValidate={onValidateObject}
processControlRef={controlRef && controlRef.bind(this)}
controlRef={controlRef}
parentIds={parentIds}
parentIds={[...parentIds, forID]}
isDisabled={isDuplicate}
isHidden={isHidden}
isFieldDuplicate={isFieldDuplicate}
Expand Down

0 comments on commit 73a5de4

Please sign in to comment.