-
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: Replace hiddenFields config with fields property instead #63127
Conversation
The typescript types were very helpful in this refactoring :) |
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. |
Size Change: +23 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
@@ -78,9 +78,7 @@ const DEFAULT_VIEW = { | |||
field: 'title', | |||
direction: 'asc', | |||
}, | |||
// All fields are visible by default, so it's | |||
// better to keep track of the hidden ones. | |||
hiddenFields: [ 'preview' ], |
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.
Question: what if you hide the preview field, but it's required in another layout?
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 still shown in the other layout (there's special treatment for media and primary fields). That said, we've been discussing with @jameskoster and @oandregal and we'll be following-up with a PR where the visible fields and fields rendering config resets when you switch layout. We found that it makes little sense to keep these when you switch layouts (as opposed to filters...)
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.
Related #57596 (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.
I'm convinced and it's a much clearer API. Tests well.
…ordPress#63127) Co-authored-by: youknowriad <[email protected]> Co-authored-by: ellatrix <[email protected]>
Related #55083
First step in #58012
What?
This PR replaces the
hiddenFields
property in the DataViews component with afields
property. And there are several reasons for this:fields
(as opposed tovisibleFields
orhiddenFields
) can allow us to do a lot more than show/hide fields. It opens the door to:fields: [ { field: 'date', renderAs: 'badge' } ]
Note
view.fields
property.Testing Instructions
Check that the different dataviews (patterns, pages...) work as expected in different layouts (grid, table, list), that you can hide/show fields in the view dropdown or in the table headers.