From 507433f45c22051ed9ea462225ecd695c7d73a27 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 27 Jul 2023 15:39:42 +0100 Subject: [PATCH] FIX: Share topic shortcut (shift+s) (#22826) This has been broken for a long time (since 04a63cfaaa) --- .../discourse/app/lib/keyboard-shortcuts.js | 5 ++- .../acceptance/keyboard-shortcuts-test.js | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js index 9fc158b1916..3316daad88d 100644 --- a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js +++ b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js @@ -106,7 +106,10 @@ const DEFAULT_BINDINGS = { "shift+k": { handler: "prevSection", anonymous: true }, "shift+p": { handler: "pinUnpinTopic" }, "shift+r": { handler: "replyToTopic" }, - "shift+s": { click: "#topic-footer-buttons button.share", anonymous: true }, // share topic + "shift+s": { + click: "#topic-footer-buttons button.share-and-invite", + anonymous: true, + }, // share topic "shift+l": { handler: "goToUnreadPost" }, "shift+z shift+z": { handler: "logout" }, "shift+f11": { handler: "fullscreenComposer", global: true }, diff --git a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js index 42ae5ee7836..688fc286bd7 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js @@ -244,4 +244,36 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) { assert.strictEqual(resetNewCalled, 1); }); + + test("share shortcuts", async function (assert) { + await visit("/t/this-is-a-test-topic/9"); + await triggerKeyEvent(document, "keypress", "J"); + assert.ok( + exists(".post-stream .topic-post.selected #post_1"), + "first post is selected" + ); + + await triggerKeyEvent(document, "keypress", "J"); + assert.ok( + exists(".post-stream .topic-post.selected #post_2"), + "pressing j moves selection to next post" + ); + + await triggerKeyEvent(document, "keypress", "S"); + assert + .dom(".d-modal.share-topic-modal") + .exists("post-specific share modal is open"); + assert + .dom("#discourse-modal-title") + .hasText(I18n.t("post.share.title", { post_number: 2 })); + await click(".modal-close"); + + await triggerKeyEvent(document, "keydown", "S", { shiftKey: true }); + assert + .dom(".d-modal.share-topic-modal") + .exists("topic level share modal is open"); + assert.dom("#discourse-modal-title").hasText(I18n.t("topic.share.title")); + + await click(".modal-close"); + }); });