CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataViews: Expose FiltersToggled subcomponent. #71907
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
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. |
@@ -0,0 +1,73 @@ | |||
/** |
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.
Just noting that all these files are not new, this is just the exact same previous components that were defined in a single file, I split them into dedicated files for clarity.
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.
Works as expected and implementation LGTM
const { isShowingFilter } = useContext( DataViewsContext ); | ||
if ( ! isShowingFilter ) { | ||
return null; | ||
} | ||
return <Filters { ...props } />; |
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.
So, the relevant change in this PR (other than splitting files) is creating this FilterToggled component, that handles the filters visibility without having to expose the DataViews context to the consumer. Is that correct?
Can we update the Filters
component instead to handle this? When is it useful having a Filters
component that doesn't handle it?
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.
Can we update the Filters component instead to handle this?
No we shouldn't because if you want to say render the "Filters" in a sidebar in your own implementation of DataViews, you can't use this with FiltersToggled
, FiltersToggled
is meant to be used in conjunction with FiltersToggle
. The only other alternative is to actually remove FiltersToggle
and let users implement it adhoc. I thought it's a nice shortcut for now, so I kept it.
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 see. Though In that case, consumers need to create their own "toogle" because FiltersToggle
will respond to clicking by changing its style from "pressed" to "not pressed", but the filters will still be visible.
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.
Yes, exactly, and FitltersToggle
is already exposed btw, and it just doesn't work on its own.
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 other words, either you use both together (FiltersToggle
and FiltersToggled
) or you don't use any (Filters
)
What?
Closes #71773
This PR exposes the
FiltersToggled
subcomponent to enable more flexible composition of DataViews filters interfaces. The component conditionally renders filters whenisShowingFilter
is true, allowing developers to position filters in custom layouts. It works in coordination withFiltersToggle
component. One component sets the state and the other one uses it.I kept the exiting Filters exposed for advanced layouts without toggle.
Testing Instructions
npm run storybook:dev
FiltersToggled
component appears/disappears in the custom layout