Skip to content
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

Improve the usability of the ObjectBrowser when inputting a manual value, checking it on blur, and adding a local validator #6576

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sneridagh
Copy link
Member

@sneridagh sneridagh commented Jan 10, 2025

Instead of requiring to press enter to validate the value, it does it on blur too.
Also, moved to use the URL validator from the main Validators.

…lue, checking it on blur, and adding a local validator.
Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit c9d50f5
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/678661ab9da4090008744c44

@sneridagh sneridagh requested review from pnicolli and a team January 10, 2025 11:02
return (
<FormFieldWrapper
{...this.props}
{...props}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing to have a thing called props which is more than just the props. Can't you just pass error separately here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davisagli check now it's better.

Thanks to the errors I've also found out that the OBW errors is messed up because how we use it as a HOC in some places :/ The errors shape switches back and forth from {} to []... We didn't realise because we never validated what's inside. Now we are dealing with a little validation inside, and since we do not handle outside validation, let's simplify it and do not take that into consideration. We can do it if we enable external validation in this widget at some point.

@sneridagh sneridagh requested a review from a team January 14, 2025 09:22
@sneridagh
Copy link
Member Author

@plone/volto-team please a look on this one?

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

News is OK. Needs technical review.

packages/volto/news/6576.bugfix Outdated Show resolved Hide resolved
if (error && url !== '') {
this.setState({ errors: [error] });
} else {
this.setState({ errors: [] });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sneridagh isn't this redundant due to the initial empty value at line 105?
https://github.com/plone/volto/pull/6576/files#diff-526a68594a32e6dd3a09f1243f7780736303aae2414bb98f8670cbdbc5f71703R105
Technically speaking react should know not to trigger a state chance if it's the same value but I
still think this is unnecessary

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ichim-david this is required to reset the state in case that the error is gone.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could reset the state at the top of the method too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants