Skip to content

display field form errors in ObjectBrowserWidget. #6787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexandreIFB opened this issue Feb 26, 2025 · 6 comments · May be fixed by #6827
Open

display field form errors in ObjectBrowserWidget. #6787

alexandreIFB opened this issue Feb 26, 2025 · 6 comments · May be fixed by #6827
Labels
01 type: bug 30 needs: triage New issue that needs confirmation before work begins

Comments

@alexandreIFB
Copy link
Contributor

alexandreIFB commented Feb 26, 2025

Describe the bug
When using the ObjectBrowserWidget, external errors (e.g. required field) do not display visual alerts in the form field. This prevents the manager from clearly identifying the issues.

Example in Teaser:
Current behavior:
Image

Expected behavior:
Image

Simulate

To simulate the issue and verify the fix:

Save Teaser without providing Target ( href).

Additional context
The problem is related to the validateManualLink and onSubmitManualLink methods, where internal errors are not being merged with external errors.

if (error && url !== '') {
this.setState({ errors: [error] });
} else {
this.setState({ errors: [] });
}

A possible solution is to combine this.state.errors with this.props.error in the render method before passing them to the FormFieldWrapper.

@alexandreIFB alexandreIFB added 01 type: bug 30 needs: triage New issue that needs confirmation before work begins labels Feb 26, 2025
@sahith-ch
Copy link

hi @alexandreIFB can i work on this issue

the solution is i have changed line 358
error={[...(this.state.errors || []), ...(this.props.error || [])]}

@wesleybl
Copy link
Member

@alexandreIFB does any core block have this problem? If not, could you suggest a change in the code to simulate the problem?

@alexandreIFB
Copy link
Contributor Author

@alexandreIFB does any core block have this problem? If not, could you suggest a change in the code to simulate the problem?

To simulate the issue and verify the fix:

Edit the schema of the Teaser block (e.g., line 109) and mark the title field as required.

Attempt to save the block without providing a title.

@wesleybl
Copy link
Member

To simulate the issue and verify the fix:

Edit the schema of the Teaser block (e.g., line 109) and mark the title field as required.

Attempt to save the block without providing a title.

@alexandreIFB could you please put this in the issue description?

@wesleybl
Copy link
Member

Edit the schema of the Teaser block (e.g., line 109) and mark the title field as required.

@alexandreIFB the title is a regular text field:

title: {
title: intl.formatMessage(messages.title),
},

I think the href field, which is already required, serves as an example, correct?

@alexandreIFB
Copy link
Contributor Author

Edit the schema of the Teaser block (e.g., line 109) and mark the title field as required.

@alexandreIFB the title is a regular text field:

volto/packages/volto/src/components/manage/Blocks/Teaser/schema.js

Lines 87 to 89 in 3c93951

title: {
title: intl.formatMessage(messages.title),
},
I think the href field, which is already required, serves as an example, correct?

You are right, I ended up confusing it with another problem, updating the problem description with more information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 type: bug 30 needs: triage New issue that needs confirmation before work begins
Projects
None yet
3 participants