Skip to content

Element deletion blockers#18728

Merged
brandonkelly merged 18 commits into5.10from
feature/deletion-blockers
Apr 26, 2026
Merged

Element deletion blockers#18728
brandonkelly merged 18 commits into5.10from
feature/deletion-blockers

Conversation

@brandonkelly
Copy link
Copy Markdown
Member

@brandonkelly brandonkelly commented Apr 16, 2026

Description

Adds the ability for elements to define blockers that should prevent their own deletion.

When the element is deleted via a supporting UI control, the element will be checked for blockers, and if there are any, a modal will be shown to the user that lists them, along with various options to resolve them.

A deletion blocker modal for a user, showing that they have two entries assigned to them, and two active subscriptions.
A deletion blocker modal for an entry, showing that it has two entries related to it.

Elements can define their own deletion blockers via the new ElementInterface::deletionBlockers() method, and plugins can register additional blockers via a new Element::EVENT_DEFINE_DELETION_BLOCKERS event.

Element deletion blocker classes must implement craft\elements\deletionblockers\DeletionBlockerInterface. A base implementation is provided by craft\elements\deletionblockers\BaseDeletionBlocker.

See for documentation on blocker/action definitions, and craft\elements\deletionblockers\EntryAuthorsBlocker for an example.

Related issues

[ci skip]
[ci skip]
# Conflicts:
#	src/templates/_elements/cardsview/elements.twig
#	src/templates/_elements/tableview/elements.twig
#	src/templates/_elements/thumbsview/elements.twig
#	src/web/assets/cp/dist/cp.js
#	src/web/assets/cp/dist/cp.js.map
Copy link
Copy Markdown
Contributor

@i-just i-just left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

I only found one proper bug, and the rest are questions/suggestions:

  1. it's not possible to delete assets via element index action on this branch (using local FS)
  2. when the deletion modal is presented, could we make the whole “accordion” title clickable (to expand), not just the icon?
  3. is it intended behaviour that you can’t use double-click to open, e.g. entries in the element index in the deletion modal? (the pencil icon works as expected)
  4. lets say you have a setup where some entries were authored by the user you want to delete; is there a reason why the “delete entries” action takes immediate effect, and reassign/remove author ones don’t?
    • if it needs to stay like this, could we tweak the confirmation message to say that this will take immediate effect? (I know most people rarely read those messages at all/in full, but it might be beneficial if/when they do)

@brandonkelly
Copy link
Copy Markdown
Member Author

lets say you have a setup where some entries were authored by the user you want to delete; is there a reason why the “delete entries” action takes immediate effect, and reassign/remove author ones don’t?

“Reassign” also takes immediate effect; “remove” doesn’t actually do anything and just lets the relationship remove itself on user delete.

The buttons are labelled to imply immediate action will be taken, so in general the behavior should be clear. The exception cases like “remove” should clarify that no action has been taken yet via their resolution message (e.g. “The entries will be updated once the users are deleted.”).

@brandonkelly brandonkelly merged commit 1dedd0d into 5.10 Apr 26, 2026
11 checks passed
@brandonkelly brandonkelly deleted the feature/deletion-blockers branch April 26, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants