Skip to content

A platform for community discussion. Free, open, simple.

UX: ask for confirmation when deleting a post using shortcut (#16526)

Andrei Prigorshnev3e0cb8ea47ea
diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js
index 9e0b1137745..f0fd230fcf9 100644
--- a/app/assets/javascripts/discourse/app/controllers/topic.js
+++ b/app/assets/javascripts/discourse/app/controllers/topic.js
@@ -702,6 +702,19 @@ export default Controller.extend(bufferedProperty("model"), {
}
},
+ deletePostWithConfirmation(post, opts) {
+ bootbox.confirm(
+ I18n.t("post.confirm_delete"),
+ I18n.t("no_value"),
+ I18n.t("yes_value"),
+ (confirmed) => {
+ if (confirmed) {
+ this.send("deletePost", post, opts);
+ }
+ }
+ );
+ },
+
permanentlyDeletePost(post) {
return bootbox.confirm(
I18n.t("post.controls.permanently_delete_confirmation"),
diff --git a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js
index 0e986f53ca0..b9d07521f2e 100644
--- a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js
+++ b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js
@@ -49,7 +49,7 @@ const DEFAULT_BINDINGS = {
"command+right": { handler: "webviewKeyboardForward", anonymous: true },
"command+]": { handler: "webviewKeyboardForward", anonymous: true },
"mod+p": { handler: "printTopic", anonymous: true },
- d: { postAction: "deletePost" },
+ d: { postAction: "deletePostWithConfirmation" },
e: { handler: "editPost" },
end: { handler: "goToLastPost", anonymous: true },
"command+down": { handler: "goToLastPost", anonymous: true },
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 0b5cb0279eb..75c3b0b7e82 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3053,6 +3053,7 @@ en:
deleted_by_author_simple: "(topic deleted by author)"
post:
+ confirm_delete: "Are you sure you want to delete this post?"
quote_reply: "Quote"
quote_reply_shortcut: "Or press q"
quote_edit: "Edit"