-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Navigation Submenu: Use a different icon for the submenu when in the list view #46075
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +205 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
if ( block.name === 'core/navigation-submenu' ) { | ||
blockInformation.icon = customLink; | ||
} |
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 think as and when we do this we need to commit to making a follow up Issue.
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 tested this and it works 🎉 . However...
I'm concerned about yet more coupling of the block editor package to specific blocks.
I'm ok with shipping this as a quick fix, but we need to have a follow up PR to try and invert the control here a bit as I describe in the specific comments below. There is already a pattern in place for labels so we could do something similar for icons.
Basically the control of the icon display should be the block's responsibility. We just need to give the block the information it requires.
Let me know your thoughts on whether you'd like to:
- ship it and commit to follow ups
- do the work now to avoid the coupling
We can discuss and merge acccordingly.
// This is a very annoying kind of exception. | ||
// Maybe we need to have a config that allows blocks | ||
// to have a different icon in the list view? |
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.
Let's do some dependency inversion on this.
I think we could consider something akin to __experimentalLabel
.
Basically I'm suggesting a way to dynamically fetch the icon which the block is responsible for defining. Perhaps by passing in a context
we can allow the block to determine which icon to display.
__experimentalIcon( attributes, { context } ) {
const { content, level } = attributes;
if ( context === 'list-view' && content ) {
// return the submenu icon
}
return // standard icon
},
// This is a very annoying kind of exception. | ||
// Maybe we need to have a config that allows blocks | ||
// to have a different icon in the list view? | ||
if ( block.name === 'core/navigation-submenu' ) { |
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.
We should track this in #46166 if it goes ahead "as is".
I don't think this approach is right. I left some more thoughts here: #46065 (comment) |
What?
Replaces the icon for the submenu block in the navigation list view
Fixes #46065
Why?
Because this block is also a link, it makes more sense to use a link icon.
How?
By adding a per-block exception in the list view. This is obviously not an ideal solution, but maybe this is ok while the off canvas editing experience is still an experiment? Can we return to it after we decide whether to proceed with the experiment?
Testing Instructions
Screenshots or screencast