-
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: centralize control of filter visibility in the Filters
component
#57056
Conversation
Size Change: -5 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Flaky tests detected in 1bc6050. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7207661920
|
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.
Thank you!
Nice, but I think we can further improve this. To me, it doesn't make much sense that if ( condensed ) {
return <AddFilter … />
}
const visibleFilters = filters.filter( ( { isVisible } ) => isVisible );
return (
<>
<AddFilter … />
{ visibleFilters.map( ( filters ) => <FilterSummary … /> }
{ visibleFilters.length > 0 && <ResetFilters … /> }
</>
); My only remaining question is whether the caller, like PagePages, should be the one setting the prop upon calling |
I thought about this and decided against. I can share my thinking, and happy to follow-up. Options I considered:
Of course, this is only about where the logic should live. Readability can always be improved, and I'm happy to act on that if I'm pointed to specifics. |
Part of #55083
See #56983 (comment)
What?
This is a code quality change: it centralizes the visibility conditions of the filters subcomponents (add filter, reset filter) in the
<Filters>
component.Testing Instructions