| Summary | A lightweight theme component that asks for confirmation before deleting a post | |
| Repository | GitHub - scavin/discourse-confirm-delete · GitHub | |
| Install Guide | How to install a theme or theme component | |
| New to Discourse Themes? | Beginner’s guide to using Discourse Themes |
Install this theme component
I’m sharing a small theme component that adds a confirmation step before a post is deleted.
By default, clicking the delete button immediately runs Discourse’s standard deletion action. This component displays Discourse’s native danger confirmation dialog first, helping prevent accidental deletions.
What does it do?
When a user clicks the Delete button on a post, the component displays a confirmation dialog:
Delete post
Are you sure you want to delete this post?
The available actions are:
- Cancel — closes the dialog without doing anything
- Delete — continues with Discourse’s original deletion action
Key Features
Uses Discourse’s native dialog UI
Uses a red danger-style Delete button
Preserves Discourse’s original deletion behavior
Does not change permission checks
Does not modify Discourse Core
No plugin required
No jQuery or window.confirm()
No DOM click simulation
Works on desktop and mobile
English and Simplified Chinese translations
Other languages fall back to English
Administrators can override the text through theme translations
How it works
The component uses the official Discourse frontend APIs:
apiInitializer- the
post-menu-buttonsvalue transformer - the built-in
dialog.deleteConfirm()service
It replaces the post menu’s Delete button component with a small wrapper. After confirmation, the wrapper calls the original deletePost action.
This means the component does not reimplement deletion, make its own API request, or bypass Discourse’s existing authorization logic.
After installation:
- Open the component in Admin → Customize → Themes
- Add it to the themes where it should be enabled
- Refresh the topic page
- Click the Delete button on a post to test the confirmation dialog
Translations
The component currently includes:
- English (
en) - Simplified Chinese (
zh_CN)
The dialog title, message, Cancel button, and Delete button all use theme translation keys. Additional translations are welcome.
Compatibility
Designed for current Discourse releases using the modern Glimmer post menu and Plugin API.
I hope this small component helps prevent accidental post deletions. Feedback, bug reports, translations, and suggestions are welcome! ![]()
