-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DataForm: Support multiple layouts and introduce the panel layout #64299
Conversation
TextProps, | ||
'size' | 'isBlock' | 'color' | 'weight' | ||
> & { | ||
export type HeadingProps = Omit< TextProps, 'isBlock' | 'color' | 'weight' > & { |
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.
The "size" definitely impacts the heading rendering, so it's a valid HeadingProps
. cc @ciampo
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -497,3 +499,10 @@ export interface SupportedLayouts { | |||
grid?: Omit< ViewGrid, 'type' >; | |||
table?: Omit< ViewTable, 'type' >; | |||
} | |||
|
|||
export interface DataFormProps< Item > { |
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 goes against what I said before about Props being collocated. That said, this one is being used in three places. Maybe we can add the DataViewsProps
here as well.
Size Change: +1.59 kB (+0.09%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
I just realized there were mockups for quick edit at #55101, I assumed the design direction for quick edit was #63624. If we want to support both "layouts", we'd need to clarify how any component works in both. Adapting components to work in two designs is a bit more work and I am slightly concerned about controlling scope for 6.7. If we don't plan to use both layouts immediately (6.7), I'd suggest we focus on a single one for now. The next two fields I plan to add to quick edit ("dates" and "status") are good examples of how "regular" and "panel" aren't always a 1:1 match. For dates, I was working at #64267. In a form-like design, we'd want dates to render along these lines: However, if we want to mimick the document inspector, we'd want something more like (note that it's not embedding the "regular" control in a modal, it's a different experience/component): |
Thinking on how to make it a 1:1 match or being able to automatically generate a variety of forms based on the existing "status" field in the document inspector:
|
I agree that it's not easy to support both at the same time. The main layout that we need for 6.7 is the "panel" one. But I see the "regular" renderer as something that forces us to think the abstraction properly and avoid optimizing too much for one renderer (panel) and break the abstractions. Also, I believe we'll quickly need the regular form renderer for the work on "DataViews for Tags and Categories and for the Media library". We want forms to create these things. |
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 looks good to me as a first step towards the direction we want to go and I believe we could land it as is.
When the explorations for more complex edit functions and combination of fields (see publish date
) start, we can reevaluate the API.
data={ data } | ||
field={ field } | ||
onChange={ onChange } | ||
hideLabelFromVision |
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.
Should this be part of the form config?
With @oandregal's comment, I'm not sure if the Edit
function needs the form
config and render accordingly what is needed, similarly with the render
function of fields that are using the viewType
. 🤔
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.
hideLabelFromVision
should be enabled by default in this "panel" layout. So for me, no it's not a form config, it's more a config to the "edit" functions (I would prefer to rename these "controls" rather than "edit"). In other words, "controls" should accept a config and be able to render controls with or without label.
I updated the storybook story to be able to pick the layout. I think this one is ready for me. |
) } | ||
onClick={ onToggle } | ||
> | ||
<field.render item={ data } /> |
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.
Haven't yet looked deeply into the code but isn't this where we render the item for the panel? I wonder why items with elements
don't render properly in the storybook (see author as number and status
as the lowercase value):
Gravacao.do.ecra.2024-08-07.as.14.19.10.mov
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 the storybook, none of those fields provide a render
function, hence they end up using the default getValue
(returns the data[id]
). This sounds like something to improve: if a field has elements, its default render function should be the label's element, not the value's element.
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 sounds like something to improve: if a field has elements, its default render function should be the label's element, not the value's element.
Indeed that could be a good improvement.
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.
Fix at #64338
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 seems there's an issue with text field types:
Gravacao.do.ecra.2024-08-07.as.14.27.27.mov
46efc74
to
bb731d7
Compare
Fixed the title field. Its render function was not handling the case of edited entities. |
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.
LGTM, thank you!
Related #55101
What?
In the quick edit panel that is being developed in the "pages" dataviews of the site editor, we want to use a design that is similar to the design we have in the "document inspector panel" of the block editor.
To do so, the current PR introduces a "type" (or the notion of layouts) to the
DataForm
component. This allows this component to be used to render regular forms or panels.Todo
Testing Instructions
1- Enable the "quick edit" experiment.
2- Open the "table" layout of the "pages" dataviews in the site editor
3- Click the "quick edit" toggle
4- Check the design of the panel and use it.