-
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
Can't cancel creation of Resuable Block #12940
Comments
Closing as duplicate of #12286 because this was suggested there already. |
@swissspidy Thanks. We need the cancel button. |
A solution here would be to use a "modal" to give a name for the block before even saving it. I tried this in a custom development at some point, I think it works fairly well. |
I was just reminded with using Gutenberg 7.7 that we are still missing the cancel button for Reusable Blocks. @youknowriad Or is there another iteration of Reusable blocks being worked on these days that this and whatever else needed is being upgraded? |
I believe this should be fixed with an alternative design. In a personal project, I implemented something close to reusable blocks but before showing the reusable block in place like we do now, I showed a small modal to enter the initial title and potentially fill other informations (icon, description..). A design like that would allow. "canceling", the current design doesn't. |
@youknowriad Any chance that personal project is open source? I'm looking to implement something similar and would be very interested in seeing some prior art. |
@chrisvanpatten no it's not unfortunately :( @mapk With this UI (block toolbar ...), it's already a reusable block. The idea I believe here is to propose this modal as soon as you click "Add to Reusable Blocks" before even persisting the reusable block. |
In regards to #12009 I notice that clicking Edit one can adjust the permalink. If one changes ones mind and does not want to save then one can just click outside of the area and the open save is automatically closed. The same method can be used for Creating a reusable block, and deciding not create one anyway. One can just click outside of the area. |
I think adding a modal is too much here. I noticed that the keyboard command for "undo" works just fine except it has a flaw. The first undo shows a weird state [block has been deleted or unavailable]. After doing "undo" again, it returns back to the original state. If we can fix this weird step in the undo process, I'd say we're golden. |
The problem here is that the block is already saved from the moment you select "Add to reusable blocks" and you can't really undo it. Doing an undo doesn't delete the block you've already created from the database. This also leads to the problem of every block having slugs like |
Is it possible for one of you or someone else to tackle this issue and fix the Reusable Block so we get correct save/cancel? Thanks. |
I think working in a "Cancel" button here which deletes the resuable block would work just fine. |
The difficulty with the proposed flow here is that while you're in the intermittent step in between creating the reusable block and saving the block, the post's content will have gone from looking like this: <!-- wp:paragraph -->
<p>Paragraph 1.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Paragraph 2.</p>
<!-- /wp:paragraph --> To looking like this: <!-- wp:paragraph -->
<p>Paragraph 1.</p>
<!-- /wp:paragraph -->
<!-- wp:block /--> If, at this point, the user saves the post but does not save the reusable block, they will have permanently lost Paragraph 2. This is why, for simplicity's sake, we opted for a flow saves the reusable block immediately. |
It seems the next step is to fix the technical hurdle you mentioned @noisysocks |
This issue is still valid. Creating a reusable block. With an existing reusable block. |
Okay, I've returned to take another look at this. So from what I gather, the reusable block creation process needs a cancel button for the primary purpose that it creates stored elements elsewhere in the backend that can't be removed by just converting it back into regular blocks. It differs from all other transforming or grouping processes in that detail. For example the Group block can group blocks together, and be ungrouped without needing a cancel option because no additional content is created elsewhere in the backend. But when I create a reusable block and convert it back into regular blocks, there remains a Reusable block in the Inserter. And that is the thing we want to avoid from being created if the click was a mistake. This messaging should then be displayed BEFORE the reusable block shows up on the page. As @youknowriad mentioned above, a modal or notification of sorts is the way to go. Riad, do you have a PR for the work you mentioned above? Aligning with that concept, Riad, I created this prototype: |
@noisysocks Robert and @youknowriad Riad. |
Describe the bug
If you accidentally click the Add to Reusable Blocks menu option, there's no Cancel button to allow you to cancel the Creation of the Block.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I should be able to cancel the creation of a Reusable Block if I accidentally click that menu option or decide that I no longer want to create a Reusable Block.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: