-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add list view inspector tab for pattern editing #74574
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
| ) } | ||
| <ContentTab contentClientIds={ contentClientIds } /> | ||
| <InspectorControls.Slot group="content" /> | ||
| <InspectorControls.Slot group="list" /> |
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 may have been for convenience, not sure, but the List tab was previously rendered as part of <StyleInspectorSlots>.
I've moved it out of that component to here, which feels like the right move to me.
|
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. |
| getMultiSelectedBlockClientIds().every( | ||
| ( id ) => getBlockName( id ) === name | ||
| ) ), | ||
| mayDisplayPatternEditingControls: false, // Section/pattern editing not yet supported on native |
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.
Claude did this, I don't know if it's the right move 🤷
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.
Are these native files still in development? The last mobile-specific edit to this file was mid-2024.
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 don't think native has had any content-only/pattern editing changes thus far? Might be wrong.
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 don't think so, so I can probably remove the changes. Last I remember the native code doesn't even compile, the CI tests are skipped.
| if ( hasContentTab ) { | ||
| tabs.push( TAB_CONTENT ); | ||
| } | ||
|
|
||
| // Add the tabs in the order that they will default to if available. | ||
| // List View > Content > Settings > Styles. | ||
| if ( hasListTab ) { | ||
| if ( hasListFills ) { | ||
| tabs.push( TAB_LIST_VIEW ); | ||
| } | ||
|
|
||
| if ( hasContentTab ) { | ||
| tabs.push( TAB_CONTENT ); | ||
| } | ||
|
|
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.
Reorders the tabs so the List Tab is after the Content tab, like the designs show.
| const shouldDisplayForPatternEditing = | ||
| context[ mayDisplayPatternEditingControlsKey ] && | ||
| ( group === 'list' || group === 'content' ); |
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.
Declares exactly which InspectorControls groups support pattern editing, otherwise the Settings tab shows in patterns as well.
| const attributes = useSelect( | ||
| ( select ) => select( blockEditorStore ).getBlockAttributes( clientId ), | ||
| [ clientId ] | ||
| ); |
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.
attributes isn't passed into the hook now that it doesn't use the BlockEdit filter, so have to select the values
| return ( | ||
| <InspectorControls group="content"> | ||
| <BlockFields | ||
| { ...props } | ||
| blockType={ blockType } | ||
| isCollapsed={ isSelectionWithinCurrentSection } | ||
| /> | ||
| </InspectorControls> | ||
| ); | ||
| } |
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.
This is quite a lot simpler now, we generally render the same thing regardless of whether in a pattern or not, the only difference is isCollapsed. 🎉
|
Size Change: +151 B (0%) Total Size: 3.06 MB
ℹ️ View Unchanged
|
| edit: BlockFieldsPanel, | ||
| hasSupport: hasBlockFieldsSupport, | ||
| attributeKeys: [], | ||
| supportsPatternEditing: true, |
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.
supportsPatternEditing is a new thing, the block edit hooks are generally optimized to only work for single selected blocks. There needs to be a way to opt in to also showing the controls for blocks that aren't currently selected, as it the case with Pattern Editing.
| return ( | ||
| <InspectorControls group="list"> | ||
| <PanelBody title={ null }> | ||
| <PanelBody title={ showBlockTitle ? blockTitle : undefined }> |
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.
Displays the block title if in a pattern and potentially showing multiple list views.
tellthemachines
left a 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.
Just catching up with the current state of the inspector controls work and things seem to be moving pretty fast so I mostly have questions at this point 😅
| getMultiSelectedBlockClientIds().every( | ||
| ( id ) => getBlockName( id ) === name | ||
| ) ), | ||
| mayDisplayPatternEditingControls: false, // Section/pattern editing not yet supported on native |
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.
Are these native files still in development? The last mobile-specific edit to this file was mid-2024.
| export const mayDisplayControlsKey = Symbol( 'mayDisplayControls' ); | ||
| export const mayDisplayParentControlsKey = Symbol( 'mayDisplayParentControls' ); | ||
| export const mayDisplayPatternEditingControlsKey = Symbol( | ||
| 'mayDisplayPatternEditingControls' |
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 almost certainly missing context here 😅 but my reading of #73845 points to all attribute types (so presumably all the inspector tabs they live in) being displayed in regular (or "design") editing mode? If that's the goal, maybe we don't need this check?
If it does turn out to be needed though, considering that contentOnly mode (not sure if we're still calling it that?) could in future be extended to other places than patterns, it might be good to use a less specific name for this Symbol such as mayDisplayContentEditingControlsKey.
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'm not sure. Showing Settings for patterns would be a lot. It'd include all of those Advanced panels.
If you're right then there's a chance it can be simplified.
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.
My read was all tabs would be available when not in contentOnly; that would just mean we would always show content/list view. I don't think the settings should be visible in contentOnly.
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, they are visible when not in contentOnly.
Example for the List Block:
Kapture.2026-01-14.at.12.59.53.mp4
I guess we shouldn't show the content tab in the situation there's no content. Or show a message. I'll look into it. |
Hmm, yeah, looks like same happens for nested/indented lists. 😱 I guess we need to figure out how to only show the top level block that has a list view.
I'll look into that, not sure why it doesn't show the appender.
It's consistent with the way 'Content' works at least 😄 . Otherwise users are required to hunt for the blocks to select in the pattern, which I'm not sure is better, it's what the experience is trying to avoid. Maybe there's another option that balances the two. I think also related is the point mentioned in the PR description about whether the lists should have some kind of drill-down like they do normally. |
…ols context value
…PatternEditingControls
6582699 to
ea030e6
Compare
I've pushed a fix for this. I think it can basically happen whenever there are no block fields, there's some logic that still shows the content tab. |
This one seems like a smaller issue for users and a List View problem, so I've made a separate issue for it -
I'll handle this one as a follow-up. |
ramonjd
left a 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.
This is testing well for me. Tentative ✅ until other folks retest based on their feedback.
I checked with and without the experiments on - it's gated so safe for follow ups I think.
Cheers!










What?
Closes #74567 - Displays the List inspector tab for Pattern Editing when a section is selected.
One caveat with this PR - when in a pattern and selecting a block from the List tab it doesn't drill down into that block like it does normally. Should it? I'm not sure, as if a child block can be selected it takes the user out of the 'pattern editing' experience. At the very least the user would need an affordance to re-select the main pattern.
How?
Technically, I think this PR moves much closer to what's described in the Block Attribute groups issue, where blocks don't have to do anything special to work with patterns, the editor controls showing the Inspector items in the correct way whether the block is within a pattern or not.
To accomplish that I've removed a previous
forceDisplayControlshack for the InspectorControlFill, and now the editor uses amayDisplayPatternEditingControlscontext value to let the Inspector Controls know whether it should render.A similar approach is used for block hooks too.
As part of this I've also ported
BlockFieldsto a block hook, and simplified it quite a bit. (I could probably move this into a separate PR, but it's dependent on this one).Testing Instructions
Prerequisite: Enable the Pattern Editing and BlockFields experiments
Screenshots or screencast