Skip to content

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

FEATURE: add "g y" keyboard shortcut to navigate to /unseen (#37033)

Régis Hanol72e4db0534af
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index ba48850a43a..189cf551d65 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4998,6 +4998,7 @@ en:
latest: "%{shortcut} Latest"
new: "%{shortcut} New"
unread: "%{shortcut} Unread"
+ unseen: "%{shortcut} Unseen"
categories: "%{shortcut} Categories"
top: "%{shortcut} Top"
bookmarks: "%{shortcut} Bookmarks"
diff --git a/frontend/discourse/app/components/modal/keyboard-shortcuts-help.gjs b/frontend/discourse/app/components/modal/keyboard-shortcuts-help.gjs
index 1cb5f868fb1..e6ad6152a2c 100644
--- a/frontend/discourse/app/components/modal/keyboard-shortcuts-help.gjs
+++ b/frontend/discourse/app/components/modal/keyboard-shortcuts-help.gjs
@@ -430,6 +430,7 @@ export default class KeyboardShortcutsHelp extends Component {
latest: buildShortcut("jump_to.latest", { keys1: ["g", "l"] }),
new: buildShortcut("jump_to.new", { keys1: ["g", "n"] }),
unread: buildShortcut("jump_to.unread", { keys1: ["g", "u"] }),
+ unseen: buildShortcut("jump_to.unseen", { keys1: ["g", "y"] }),
categories: buildShortcut("jump_to.categories", { keys1: ["g", "c"] }),
top: buildShortcut("jump_to.top", { keys1: ["g", "t"] }),
bookmarks: buildShortcut("jump_to.bookmarks", { keys1: ["g", "b"] }),
diff --git a/frontend/discourse/app/services/keyboard-shortcuts.js b/frontend/discourse/app/services/keyboard-shortcuts.js
index 2896229a387..3a708fb9df7 100644
--- a/frontend/discourse/app/services/keyboard-shortcuts.js
+++ b/frontend/discourse/app/services/keyboard-shortcuts.js
@@ -77,6 +77,7 @@ const DEFAULT_BINDINGS = {
"g l": { path: "/latest", anonymous: true },
"g n": { path: "/new" },
"g u": { path: "/unread" },
+ "g y": { path: "/unseen" },
"g c": { path: "/categories", anonymous: true },
"g t": { path: "/top", anonymous: true },
"g b": { path: "/my/activity/bookmarks" },
diff --git a/frontend/discourse/tests/acceptance/keyboard-shortcuts-test.js b/frontend/discourse/tests/acceptance/keyboard-shortcuts-test.js
index cf59426614c..d2e90ee91a0 100644
--- a/frontend/discourse/tests/acceptance/keyboard-shortcuts-test.js
+++ b/frontend/discourse/tests/acceptance/keyboard-shortcuts-test.js
@@ -125,6 +125,9 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
server.get("/new.json", () => {
return helper.response(topicList);
});
+ server.get("/unseen.json", () => {
+ return helper.response(topicList);
+ });
server.put("/topics/reset-new", () => {
resetNewCalled += 1;
return helper.response({});
@@ -271,6 +274,13 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
await click(".modal-close");
});
+ test("g y navigates to /unseen", async function (assert) {
+ await visit("/");
+ await triggerKeyEvent(document, "keypress", "G");
+ await triggerKeyEvent(document, "keypress", "Y");
+ assert.strictEqual(currentURL(), "/unseen");
+ });
+
module("context aware create new shortcuts", function () {
test("C key opens composer in new topic mode from topics list", async function (assert) {
await visit("/");