-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Navigation Submenu: Refactor to use the block supports function #48936
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
Changes from 1 commit
17f38a2
996abf1
68526bd
44fd29c
02b199b
99bc885
bb098ed
4807578
168a906
67f9d9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -200,9 +200,8 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { | |
|
|
||
| // This allows us to be able to get a response from gutenberg_apply_colors_support. | ||
| $block->block_type->supports['color'] = true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not rely on the actual block supports. If someone decides to disable block supports for this block then we should respect that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do that then users will be able to modify the settings for the submenu block in the UI, independently from the parent block. I think what we need to do is move the color settings from the navigation block to the submenu block, which will require a UI update and a block transform, and a lot of thinking about backwards compatibility. I do think we should do all of that, but if I had done it in this PR you'd be telling me it was too big, so this is just a first step toward that goal.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok sure. I agree with small PRs. I was thinking that as So yes I think this workaround is an ok tradeoff for being able to utilise the standardised color code generation. What's the long term plan? Expose UI in the Submenu Block to allow changing colors on individual blocks but have the initial settings still coming from the parent Nav block?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree that we still need a way to set it on the Nav block so that you don't need to change it for every child, but I've not given much thought to how that would work in practice yet.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the same gut reaction initially and even tried to code a variant that just relies on block supports, but we do have some blockers there. However:
@jasmussen is that a problem really? |
||
| $colors_supports = gutenberg_apply_colors_support( $block->block_type, $attributes ); | ||
|
|
||
| $css_classes = 'wp-block-navigation__submenu-container'; | ||
| $colors_supports = gutenberg_apply_colors_support( $block->block_type, $attributes ); | ||
| $css_classes = 'wp-block-navigation__submenu-container'; | ||
| if ( array_key_exists( 'class', $colors_supports ) ) { | ||
| $css_classes .= ' ' . $colors_supports['class']; | ||
| } | ||
|
|
||
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.
Is it ok to modify this?