Skip to content
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

Warn users prior to removal of critical blocks in blog templates #40618

Closed
jameskoster opened this issue Apr 26, 2022 · 13 comments · Fixed by #51145
Closed

Warn users prior to removal of critical blocks in blog templates #40618

jameskoster opened this issue Apr 26, 2022 · 13 comments · Fixed by #51145
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing")

Comments

@jameskoster
Copy link
Contributor

jameskoster commented Apr 26, 2022

In the site editing context there are certain blocks that you shouldn't delete outside of edge cases – Post Content and Query Loop can cause a lot of damage if removed. It would be good to display a confirmatory modal when the user attempts to remove them.

Screenshot 2023-05-19 at 15 41 22

To begin with we can display this when editing a blog template (Index / Home). But it would be good to expand that to include archive and singular templates after.

@jameskoster jameskoster added the [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") label Apr 26, 2022
@fabiankaegy
Copy link
Member

This feature would also be great for 3rd party blocks.

I can think of 2 different ways of approaching it.

1. On a Block Level

The first thing that came to mind was building this out as a block support property that blocks can define.

block.json

{
    "supports": {
        "warnBeforeRemoval": true
    }
}
{
    "supports": {
        "warnBeforeRemoval": [ 'single-post', 'single-page' ]
    }
}

_Note: Not an actual API. Just as an example

2. On a Template Level

Another option is to expose this level of control on the template level.
Maybe a Template could define blocks that are recommended and the warning gets shown when these recommended blocks are removed.

In either case, it should be filterable by theme / plugin authors. For the Post Title for example there are also other 3rd party blocks that save to the post title field and therefore are an actual replacement and it can make sense to have other recommended blocks than vanilla core would have :)

@jameskoster
Copy link
Contributor Author

The block level approach sounds good as it would allow us to cover things like removing Post Template from Query Loop – something that can happen in both the site editor and the post editor.

@talldan
Copy link
Contributor

talldan commented May 6, 2022

The block level approach sounds good as it would allow us to cover things like removing Post Template from Query Loop – something that can happen in both the site editor and the post editor.

Could it also be locked, or is there a use case for removing Post Template?

@jameskoster
Copy link
Contributor Author

or is there a use case for removing Post Template?

Perhaps edge cases like elaborate designs where you want pagination in a different location to the posts list? 🤔

@mtias
Copy link
Member

mtias commented Oct 10, 2022

I think this is a good opportunity to communicate the more intricate aspects of templates and content management, so we should be more forthcoming on why something is not advised — "this block is what displays the content of your posts, removing it would mean all your posts show empty in their permalink" or something.

@annezazu
Copy link
Contributor

Based on experience with the FSE Outreach Program, I think this would go a long way towards guiding folks towards interacting with the pieces of the site editor/site editing experience appropriately/in a way that will lead to the outcomes they might want. Keen to get something in place and do a round of testing!

@jameskoster
Copy link
Contributor Author

There's quite a lot of nuance to consider here. Removing a Query block from the Home template might yield a different message to removing it from the Index, Front Page, or Tag template. If comments are disabled for a particular post / post type, then we don't need to display a warning.

The first step is probably to identify which blocks prompt a warning, and then come up with generic-but-useful messages for each of them, and the basic conditions upon which they appear.

@ntsekouras
Copy link
Contributor

Should we consider custom handling to just a few of these blocks for now before looking at an abstraction(like supports)?

@jameskoster
Copy link
Contributor Author

It would be good to handle some of the more important cases. Post Content on Singular templates, and Query Loop on archive templates spring to mind.

@fabiankaegy
Copy link
Member

I agree there are some core blocks that really should get this sooner than later so it might make sense to add a custom solution for them first.

But I do want to also make the case that third-party blocks are very much in need of this as a standardized API. So it would be great if custom solutions don't mean that we never get a public API for it :)

@mtias
Copy link
Member

mtias commented Jan 23, 2023

Let's start with custom handling until the UX is sorted out and proven.

@mtias
Copy link
Member

mtias commented May 18, 2023

Can we start just with post content and query blocks in blog templates?

@richtabor
Copy link
Member

I think this is a good opportunity to communicate the more intricate aspects of templates and content management, so we should be more forthcoming on why something is not advised — "this block is what displays the content of your posts, removing it would mean all your posts show empty in their permalink" or something.

This is important; including the "why".

@priethor priethor added this to Polish May 18, 2023
@priethor priethor moved this to Needs development in Polish May 18, 2023
@jameskoster jameskoster changed the title Make it possible for blocks to warn users prior to removal Warn users prior to removal of critical blocks in blog templates May 19, 2023
@tellthemachines tellthemachines self-assigned this May 30, 2023
@priethor priethor removed the Needs Dev Ready for, and needs developer efforts label May 30, 2023
@tellthemachines tellthemachines moved this from Needs development to In progress in Polish May 30, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jun 1, 2023
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing")
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

9 participants