A platform for community discussion. Free, open, simple.
FIX: Share topic shortcut (shift+s) (#22826)
David Taylor507433f45c22
diff --git a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.jsindex 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.jsindex 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");+ });});