-
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
Disable Width Settings in Button Block #66254
base: trunk
Are you sure you want to change the base?
Disable Width Settings in Button Block #66254
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. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @karthick-murugan! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Hi @karthick-murugan |
Good job! I like the forward movement toward handling this pretty common request (disabling block settings). Aside from the |
+1 to this. If the approach in this PR is correct, I could see this being applied to all block settings. This is a very common feature request. But we need to make sure this is the correct course of action more broadly. Thoughts on this from an architectural standpoint @youknowriad @mtias? |
theme.json is the right approach for these things but I wouldn't tie this to a block. We should think about "block supports" more globally.
Based on this, I think I'd be ok having a I would love if we can do an audit of existing "width" controls in the core blocks to see if it adapts to all of these. Now for the implementation, the following should probably be enough to retrieve the right config for a given block.
|
width and height block supports are tracked here #28356 |
The search block has a width option too |
What?
Fixes Part of this issue
This PR introduces the ability to disable the button block's width settings through the theme.json file.
Why?
This functionality is important for themes that are tailored to specific designs, where controlling the button width setting may be unnecessary or undesired. This provides better flexibility for theme developers, allowing them to disable the width controls as needed.
How?
The edit.js file of the button block has been updated to retrieve the width value from the theme’s theme.json file. If the width setting is disabled (i.e., set to false), the width panel is no longer displayed in the editor for the button block.
Testing Instructions
Checkout this branch to your local
Include the following JSON object within the settings section of the theme.json file for the active theme:
Testing Instructions for Keyboard
None
Screenshots or screencast
For no changes in theme.json or adding width value to true
For theme.json width value false