-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DataViews: fix field reordering and visibility logic #64999
DataViews: fix field reordering and visibility logic #64999
Conversation
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. |
Flaky tests detected in 2c2d801. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10681307930
|
This actually stems from wanting to fix this issue #64381 (comment) but then I noticed there was a few other ones. |
I feel we should be able to show the fields individually in separate columns if we choose to. |
: enableHiding, | ||
}; | ||
} ); | ||
if ( view.type === LAYOUT_TABLE && view.layout?.combinedFields ) { |
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 think this works for now, but my thinking is that ultimately, we should find a way for the layouts to actually "inject" logic here. Or (which is what I had in mind) to have some kind of a slot and the "properties" area be specific per layout. For instance in "table", we should be able to "combine" fields if we want.
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 agree. If we aim to make the layouts "registerable/unregisterable" by 3rd parties we cannot have this kind of logic in the view config (or any other component).
I've looked at the current usage of layouts in this component and this is what I see:
- grid layout check to show/hide the density picker.
- table layout check to show/hide the ability to reorder fields.
- table layout check to inject "virtual fields" (aka combined).
All of them could be solved by providing a layout.supports
thing somewhere. Using that approach, it'd still be DataViews' responsibility to define which "features" are supported.
Or (which is what I had in mind) to have some kind of a slot and the "properties" area be specific per layout. For instance in "table", we should be able to "combine" fields if we want.
This approach would be a lot more open. However, every layout would have to implement the same actions (reordering, visibility, etc.).
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 any case, not for this PR 😅
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.
Actually, layout.supports
could also be a nice thing to have for consumers that want to "lock in" (aka remove options) a bit more the user experience.
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 approach would be a lot more open. However, every layout would have to implement the same actions (reordering, visibility, etc.).
Yes, but for list view we have badges..., for grid we have columns and rows...
I could be convinced otherwise, but I can't imagine use cases for this. Anyway, if we wanted this, we should consider it at the user level (expose them in the view config under "hidden fields"). A feature that is related is the ability for users to "combine"/"split" fields. Not sure how both things would work together, so I'd rather leave this out of this PR. |
I agree that if we allow people to combine and split combined fields, it becomes kind of useless. I'm fine keeping the current state of the PR. |
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 have thoroughly tested the reordering and hiding functionality of patterns, templates, and pages view, and everything seems to be working well. I didn't encounter any unexpected issues with the code changes, so it looks like we can go ahead and merge this change. 👍
Part of #55083
What & Why?
This PR fixes a few issues around field reordering & visibility:
view.fields
.view.fields
is not provided: reordering fields should work.view.fields
is not provided: the properties panel in view config should be visible. Reordering & visibility was still available via the table header.view.fields
is not provided: display combined fields properly.How?
Refactored the logic that deals with visibility & reordering fields.
Testing Instructions
Displays moving controls for combined fields
Prevent fields that are part of a combined field from being displayed when they are listed in
view.fields
title
inview.fields
for the Templates Page.title
field (withTemplate
label) is not visible in the table and the view config properties panel.Do not display hidden fields that cannot be made visible in view config
npm install && npm run storybook:dev
.DataViews
in storybook and verify thetype
field is not listed in hidden fields.When
view.fields
is not provided: reordering fields should work.view.fields
andview.layout.combinedFields
for the Templates Page.Before
240903-table-header-with-no-view-fields-before.mov
After
240903-table-header-with-no-view-fields-after.mov
When
view.fields
is not provided: the properties panel in view config should be visibleview.fields
andview.layout.combinedFields
for the Templates Page.When
view.fields
is not provided: display combined fields properlyview.fields
for the Templates Page.template
pluspreview
andauthor
which are not part of any combination):