diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index c521376f2e..c8b63827a5 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/frontend_tests/node_tests/hotkey.js @@ -245,6 +245,16 @@ function stubbing(func_name_to_stub, test_function) { assert_mapping(':', 'emoji_picker.toggle_emoji_popover', true); assert_mapping('G', 'navigate.to_end'); assert_mapping('M', 'muting_ui.toggle_mute'); + + // Test keys that work when a message is selected and + // also when the message list is empty. + assert_mapping('n', 'narrow.narrow_to_next_topic'); + + global.current_msg_list.empty = return_true; + assert_mapping('n', 'narrow.narrow_to_next_topic'); + + global.current_msg_list.empty = return_false; + }()); (function test_motion_keys() { diff --git a/static/js/hotkey.js b/static/js/hotkey.js index a1653e147b..fc68295b89 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -115,7 +115,7 @@ var keypress_mappings = { 105: {name: 'message_actions', message_view_only: true}, // 'i' 106: {name: 'vim_down', message_view_only: true}, // 'j' 107: {name: 'vim_up', message_view_only: true}, // 'k' - 110: {name: 'new_stream', message_view_only: false}, // 'n' + 110: {name: 'n_key', message_view_only: false}, // 'n' 113: {name: 'query_users', message_view_only: false}, // 'q' 114: {name: 'reply_message', message_view_only: true}, // 'r' 115: {name: 'narrow_by_recipient', message_view_only: true}, // 's' @@ -591,9 +591,11 @@ exports.process_hotkey = function (e, hotkey) { subs.view_stream(); } return true; - case 'new_stream': + case 'n_key': if (exports.is_subs()) { subs.new_stream_clicked(); + } else { + narrow.narrow_to_next_topic(); } return true; case 'open_drafts': diff --git a/templates/zerver/help/keyboard-shortcuts.md b/templates/zerver/help/keyboard-shortcuts.md index f1f266a756..11427a2552 100644 --- a/templates/zerver/help/keyboard-shortcuts.md +++ b/templates/zerver/help/keyboard-shortcuts.md @@ -69,6 +69,8 @@ Zulip keyboard shortcuts are divided into four categories: messages with the topic of the selected message (outlined in blue). * **Narrow to all private messages**: `P` - This shortcut narrows the view to show all of the user's private messages. +* **Narrow to next unread topic**: `n` - This shortcut narrows the + view to the next unread topic in the stream sidebar. * **Cycle between stream narrows**: `A` and `D` - This shortcut allows the user to cycle through the narrows showing the messages of a stream according to Stream order in the left sidebar. `A` allows the user diff --git a/templates/zerver/keyboard_shortcuts.html b/templates/zerver/keyboard_shortcuts.html index 9423dd8054..93e0ab76cc 100644 --- a/templates/zerver/keyboard_shortcuts.html +++ b/templates/zerver/keyboard_shortcuts.html @@ -106,6 +106,10 @@ P {% trans %}Narrow to all private messages{% endtrans %} + + n + {% trans %}Narrow to next unread topic{% endtrans %} + A or D {% trans %}Cycle between stream narrows{% endtrans %}