-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Buttons: Disable edit as HTML support #49097
Conversation
But what is causing this error? Why is the block markup not visible in the input field when the Edit HTML option is selected? |
Removing this option may conflict with #47868 |
Which block's markup?
Can you give me more details? For example, how disabling can UI action conflict with attribute supports? The individual Button blocks can still be edited as HTML. This is only disabled for a wrapper. |
I did not understand why editing this block would be more prone to problems compared with for example the image block which has many more lines of code. I also do not know what the term "leaf blocks", that is quoted above, refers to. Without the PR applied, (6.2 current nightly, no Gutenberg) I added the block in the editor and selected the Edit as HTML option. Adding anything inside the textarea causes a block validation error. So the questions are, why is it empty and breaking?, are there any benefits to fixing the underlying issue instead of removing it?
You are right, I mixed up the block names and got confused about the markup being different if there is no text content in the button. |
I think you're editing a Button block without content; that's when you get empty input. I believe that's by design. The "leaf block" refers to the inner block, in this case.
The bug has been around for a while now, as you can see by the linked similar issues. I agree this is a temporary solution, but we already use it in practice. Parsing markup again on the block mode switch has its downside. See #43219. Screenshot |
But back to the PR; I still think that it will not be enough of an improvement if only the parent buttons block is fixed, because it is too easy to cause a block validation error also with the button block. |
I think that's the general problem with the "Edit as HTML" or "Code Editor" modes. It's easy to mess up the blocks. Probably not something I can resolve here and now 😢 |
All I am suggesting is adding
to block.json for the |
That was initially proposed in this PR #20948 (comment) and then reverted. The current policy seems to disable it for container blocks (mostly). |
Thank you, @talldan! I agree. The Button block has a separate bug, and I'll try to look into that shortly.
Removing the feature that's been around this long would be hard. Maybe we should only allow it for Admin users. P.S. What do you think about this solution? Should we go with it? |
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.
P.S. What do you think about this solution? Should we go with it?
Sounds good. I wonder about List and Quote, which also now have this issue 😄
We can apply the same "solution" for other parent blocks 😅 P.S. The Button block displays an empty input because it renders nothing when there's no text specified. See #29781. |
Well spotted. I guess it's fine to keep it as it is, it just means anyone editing as HTML has to type the whole block html in when there's no text. |
What?
Resolves #49095.
A similar PRs: #11785, #39318.
PR disabled HTML editing for the Buttons block.
Why?
Testing Instructions
Testing Instructions for Keyboard
Same as general instruction.
Screenshots or screencast