From cb91d7037f574fecb1d36f4a23717d123f0ca85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 17 Jan 2021 08:28:52 +0100 Subject: [PATCH 1/4] Added search shortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/LoggedInView.tsx | 8 ++++++++ src/components/structures/RoomView.tsx | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index ec5afd13f0..f34427ba88 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -419,6 +419,14 @@ class LoggedInView extends React.Component { handled = true; } break; + case Key.F: + if (ctrlCmdOnly) { + dis.dispatch({ + action: 'focus_search', + }); + handled = true; + } + break; case Key.BACKTICK: // Ideally this would be CTRL+P for "Profile", but that's // taken by the print dialog. CTRL+I for "Information" diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 0ee847fbc9..c4e88b5781 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -748,6 +748,9 @@ export default class RoomView extends React.Component { }); } break; + case 'focus_search': + this.onSearchClick(); + break; } }; From 8853508363022bcbebea9bc699c7bc046be7368d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 17 Jan 2021 16:36:54 +0100 Subject: [PATCH 2/4] Added search shortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/accessibility/KeyboardShortcuts.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/accessibility/KeyboardShortcuts.tsx b/src/accessibility/KeyboardShortcuts.tsx index 48d0eb2ab1..7a0ba58c97 100644 --- a/src/accessibility/KeyboardShortcuts.tsx +++ b/src/accessibility/KeyboardShortcuts.tsx @@ -168,6 +168,12 @@ const shortcuts: Record = { key: Key.U, }], description: _td("Upload a file"), + }, { + keybinds: [{ + modifiers: [CMD_OR_CTRL], + key: Key.F, + }], + description: _td("Search (must be enabled)"), }, ], From e7384f829a73f938055c3e260f5bb67bc04d6c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 17 Jan 2021 16:44:29 +0100 Subject: [PATCH 3/4] Made search shortcut optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/LoggedInView.tsx | 2 +- .../views/settings/tabs/user/PreferencesUserSettingsTab.js | 1 + src/settings/Settings.ts | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index f34427ba88..5f276f1e7a 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -420,7 +420,7 @@ class LoggedInView extends React.Component { } break; case Key.F: - if (ctrlCmdOnly) { + if (ctrlCmdOnly && SettingsStore.getValue("ctrlFForSearch")) { dis.dispatch({ action: 'focus_search', }); diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js index 4d8493401e..a32549b326 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js @@ -52,6 +52,7 @@ export default class PreferencesUserSettingsTab extends React.Component { 'showImages', 'showChatEffects', 'Pill.shouldShowPillAvatar', + 'ctrlFForSearch', ]; static GENERAL_SETTINGS = [ diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index b239b809fe..fd03de1eb5 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -331,6 +331,11 @@ export const SETTINGS: {[setting: string]: ISetting} = { displayName: _td("Show typing notifications"), default: true, }, + "ctrlFForSearch": { + supportedLevels: LEVELS_ACCOUNT_SETTINGS, + displayName: isMac ? _td("Use Command + F to search") : _td("Use Ctrl + F to search"), + default: false, + }, "MessageComposerInput.ctrlEnterToSend": { supportedLevels: LEVELS_ACCOUNT_SETTINGS, displayName: isMac ? _td("Use Command + Enter to send a message") : _td("Use Ctrl + Enter to send a message"), From fb60ba3482c2d7f94b03df28c766269968a90186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 17 Jan 2021 16:45:29 +0100 Subject: [PATCH 4/4] i18n MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/i18n/strings/en_EN.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8739d0cf2f..f0d0be3e1b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -797,6 +797,8 @@ "Enable big emoji in chat": "Enable big emoji in chat", "Send typing notifications": "Send typing notifications", "Show typing notifications": "Show typing notifications", + "Use Command + F to search": "Use Command + F to search", + "Use Ctrl + F to search": "Use Ctrl + F to search", "Use Command + Enter to send a message": "Use Command + Enter to send a message", "Use Ctrl + Enter to send a message": "Use Ctrl + Enter to send a message", "Automatically replace plain text Emoji": "Automatically replace plain text Emoji", @@ -2705,6 +2707,7 @@ "Dismiss read marker and jump to bottom": "Dismiss read marker and jump to bottom", "Jump to oldest unread message": "Jump to oldest unread message", "Upload a file": "Upload a file", + "Search (must be enabled)": "Search (must be enabled)", "Jump to room search": "Jump to room search", "Navigate up/down in the room list": "Navigate up/down in the room list", "Select room from the room list": "Select room from the room list",