-
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
BlockInspector: Conditionally render Inspector Control Tabs depending on Write Mode #67149
base: trunk
Are you sure you want to change the base?
BlockInspector: Conditionally render Inspector Control Tabs depending on Write Mode #67149
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
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. |
I tested this PR in the Gutenberg PR reviewer, and it works perfectly for the write mode and when the "Show Template" option is active. However, with this condition, the inspector controls are not displayed in any mode. Ideally, these controls should be visible in design mode to allow layout editing. That said, I noticed that even in the trunk, the inspector controls are not shown when design mode is activated. I’ve attached a video of the testing process below for reference. 67149.mp4 |
Hi, @dhruvang21, and thanks for testing the PR. I noticed this as well, but the code in this PR is not related to that bug and this PR was to address a slightly different issue. I feel a separate issue should be created regarding this bug as it's present in the Trunk and should be patched in that issue. |
Showing or hiding the tabs is a second-order effect of having the content block selectable. My issue is geared towards making the editor feel the same between post and site editing experiences. In my opinion the post content block should not be selectable when it's not editable. It should likely be the same experience as when you're editing in the post editor today. |
Hi @richtabor, Thank you for reviewing the PR. To make the parent Post Content block unselectable, one approach is to remove it entirely from the block tree, similar to how it's handled in the generic post editor. However, this approach presents challenges. The Post Content block serves as a container that holds all inner blocks together. Removing it from the root and displaying its inner blocks directly in its place might seem to work initially, but it complicates the application of styles. Specifically, applying styles solely to the inner container becomes problematic without a defined wrapper like the Post Content block. In my opinion, retaining the Post Content block—or a similar container block—is essential to ensure proper structural integrity and styling of its inner blocks. Also, the previous proposed solution of hiding the controls seems like the best bet for this at the moment. Looking forward to hearing your thoughts! |
I think it should work just like the post editor today, where it's not selectable. |
Fixes: #67129
What?
This PR resolves a bug that causes block controls to be displayed when both "Show Template Mode" and "Write Mode" are enabled. In this scenario, the controls should not be visible, and the block should remain non-editable, as "Write Mode" is specifically intended for creating content.
How?
The Inspector Controls were conditionally rendered to stay hidden when viewing with Show Template Mode and Write Mode enabled, thereby preventing the user from updating the Block.
Testing Instructions
Screencast
Screen.Recording.2024-11-20.at.3.14.14.PM.mov