-
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
DataViews: Replace supportedLayouts prop with defaultLayouts prop instead #63287
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. |
Size Change: +41 B (0%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
@@ -61,7 +61,7 @@ export function filterSortAndPaginate< Item >( | |||
} ); | |||
} | |||
|
|||
if ( view.filters?.length > 0 ) { | |||
if ( view.filters && view.filters?.length > 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.
What does this change?
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 made view.filters optional that way folks don't have to define it if they don't have 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.
Yeah, I meant why the previous view.filters?.length
wasn't enough..
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.
Looks good and tests well. Thank you!
…tead (WordPress#63287) Co-authored-by: youknowriad <[email protected]> Co-authored-by: ntsekouras <[email protected]>
…tead (WordPress#63287) Co-authored-by: youknowriad <[email protected]> Co-authored-by: ntsekouras <[email protected]>
Related #55083
What?
Each time we change the "layout" of the DataViews component, we often need to change the fields configuration or tweak the "layout" property of the "view" object... Basically what we're doing here is that we're setting a default value for the "view" object (keeping filters, search...)
Also, on the other hand, when using the DataViews component, we define the "supportedLayouts" prop.
For me, this suggests that these two things are the same and only thing. This PR combines these props in a unique
defaultViews
prop. This is going to be more important with the introduction of field combination as the differences between view types are growing over time.Testing Instructions
This is an API change, but there should be no functional change.