RFC: Enable full customization of Query Loop block inspector controls#43675
RFC: Enable full customization of Query Loop block inspector controls#43675sunyatasattva wants to merge 4 commits intoWordPress:trunkfrom
Conversation
Add an attribute `disabledInspectorControls` to let users decide which controls should be displayed.
|
Thanks for the PR @sunyatasattva! A couple of thoughts:
|
|
@sunyatasattva, nice progress on making the Query Loop block easy to customize for different post types 🤩 Let's try to break down this work into smaller task like the one proposed by @ntsekouras in #43632 so we address individual aspects separately.
That's another task that can be done in isolation and will make it easier to review the actual changes proposed in this PR. |
|
Should we close this PR as "stale"? |
|
Yep, we have moved to a different direction. I'm going to close this one. |
What?
This PR enables developers to completely extend the Query Loop block options, deciding which settings should be available and which should not.
Why?
Developers might want to create Query Loop block variations which are more specific to their environment, and, as such, don't require all of the settings available by default on the Query Loop block. Even further, some of these settings might break block variations.
How?
This PR proposes a way to enable this customization that is completely backwards compatible, and enables a simple API for developers to hook into and extend the settings.
disabledInspectorControlshas been added to the block. Developers can pass an array of strings corresponding to the keys of the settings that they want to disable to not render them on the inspector sidebar. Since we are not using TypeScript, perhaps adding a clear JSDoc documentation of the keys available by default could be helpful. However, no harm is done if wrong strings are passed, and the block behaves normally when the attribute is an empty array orundefined, preserving backwards compatibility.disabledInspectorControlsalso accept a list of strings corresponding to the collapsed filters. However, since filters have been moved to aToolsPanel, in order to allow developers to extend that panel and completely integrate new optional filters to the inspector, a new WordPress filter has been added (provisional name:editor.QueryLoop.FilterControls, naming convention inspired by filters found incomponents/Autocomplete).inspector-control/index.jsfile into their own file, cutting the size of that file by more than half and making it more readable. Now, it is much clearer what each component is responsible for, and what properties are required, instead of having all the logic mixed into one component.@gziolo @ntsekouras I'm publishing this as a Draft PR to get your comments before I submit it for full review, in case you disagree with some of the approach taken here.
Testing Instructions
disabledInspectorControlsattribute, like so:ToolsPaneldropdown.Screenshots or screencast
Notice the missing settings on the right, and a new filter within the Filters
ToolsPanel.