-
-
Notifications
You must be signed in to change notification settings - Fork 778
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
Volto form block fixes #6370
base: main
Are you sure you want to change the base?
Volto form block fixes #6370
Conversation
✅ Deploy Preview for plone-components canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add release notes and fix the lint errors and failing unit tests.
This PR should also render its Storybook. We recently merged a PR that should fix the pull request preview build on Netlify: The Netlify build currently fails to recognize changes in the most recent commit: |
6d9bc8a
to
be53373
Compare
988b47e
to
dd5a050
Compare
This caused the object_browser widget loosing the mode and return props which got the default "multiple", "multiple" values even when "image", "single" was desired. As a consequence this broke the preview images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this has a lot of useful improvements, but still some rough edges and missing docs.
packages/volto/src/components/theme/Widgets/HiddenWidget.test.jsx
Outdated
Show resolved
Hide resolved
type: 'string', | ||
title: intl.formatMessage(messages.queryParameterName), | ||
description: intl.formatMessage(messages.queryParameterNameDescription), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried adding a queryParameterName to a field in a content type schema, but it doesn't do anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a property of the field which can be used by the actual view (or not). In this case the content type schema editing view doesn't use it but could in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesn't do anything, it's bad UX to show it when editing a content type schema in the schemaeditor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, the schema widget is not tied to a specific form library and set of widgets. You can decide to use your own set of widgets which do make use of these values. This is not something new in Plone, there are plenty of fields on a content type or settings in the control panels which are not used by stock plone or shown in the ui but can be used if somebody wants that.
placeholder: { | ||
type: 'string', | ||
title: intl.formatMessage(messages.placeholder), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried adding a placeholder to a text field in a content type schema, but it didn't show up when I edited the content type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a property of the field which can be used by the widget (or not). In this case the current widget in Plone doesn't use the value but when you use a custom widget (react-aria-components for example) you can use those properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't just add properties to the schema editor that look useful but don't do anything. That's a recipe for frustration!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor MyST enhancements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments, humongous work! Congrats!
* @function RadioGroupWidget | ||
* @returns {string} Markup of the component. | ||
*/ | ||
class RadioGroupWidget extends Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
id="fieldset-default-field-label-my-field" | ||
> | ||
My field | ||
</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the vocabulary being passed in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge and very very useful work, thanks!!!! Left a few notes with the goal of having this as polished as possible.
basic | ||
secondary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried these props could be spread unknowingly to the final html <button>
that is rendered, if the provided custom button does not handle them, and it is likely that this is the case because Button components are usually handling a bunch of props and assuming other props are standard html and just spread them in the html button. This causes annoying warnings in the browser console telling you you are using unknown attributes.
I would try to set these (and others like floated
) only if a custom button is not provided, maybe by creating smaller preset buttons above, at line 740, or even outside of this component. Ideas or thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a blocker for me, but I would honestly not create new components as class components ever again, unless there is a specific reason, for example asyncConnect which acts weird in function components.
|
||
export const CheckboxGroupWidgetComponent = injectIntl(CheckboxGroupWidget); | ||
|
||
export default compose( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep the class component here, I would remove the compose
call here since there is only one function being composed
|
||
export const RadioGroupWidgetComponent = injectIntl(RadioGroupWidget); | ||
|
||
export default compose( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I would remove the useless compose
call here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need views widgets for radiogroup, checkboxgroup and time widgets?
.toLowerCase() | ||
.replace(/[\s-]+/g, '_') | ||
.replace(/[^\w]+/g, ''); | ||
let i = 1; | ||
|
||
if (includes(slugs, slug)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also use standard js here instead of lodash
@@ -54,6 +54,10 @@ | |||
} | |||
} | |||
|
|||
.ui.form .ui.checkbox { | |||
margin: @8px 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@8px
is a typo or is it a syntax I am not familiar with?
map( | ||
['URL', 'Password', 'label_password_field', 'Email', 'label_email'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would start using standard js for these easy things, instead of using lodash. Nowadays we don't need lodash for these simple things like map. Also, since we are not really using the output from map here, I would suggest simply doing
['URL', 'Password', 'label_password_field', 'Email', 'label_email'].forEach
@@ -927,6 +945,8 @@ class Form extends Component { | |||
), | |||
...map(item.fields, (field, index) => ( | |||
<Field | |||
widgets={this.props.widgets} | |||
component={this.props.component} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this.props.component
is a Form component of some kind here, either the default or a provided one, so maybe this should not be passed to the Field component, right?
If your pull request closes an open issue, include the exact text below, immediately followed by the issue number. When your pull request gets merged, then that issue will close automatically.
Closes #