FIX: Share topic shortcut (shift+s) (#22826)

This has been broken for a long time (since 04a63cfaaa)
This commit is contained in:
David Taylor 2023-07-27 15:39:42 +01:00 committed by GitHub
parent 7b3f9dc86b
commit 507433f45c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -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 },

View File

@ -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");
});
});