From d01f86af22fdbce117d14ca8b1befd2d40e9fff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 18 Jul 2023 01:06:53 +0200 Subject: [PATCH] Make Compose hotkey open Compose modal when required MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/ui/components/modals/hotkeys-modal.tsx | 2 +- app/soapbox/features/ui/util/global-hotkeys.tsx | 5 +++-- app/soapbox/locales/en.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/soapbox/features/ui/components/modals/hotkeys-modal.tsx b/app/soapbox/features/ui/components/modals/hotkeys-modal.tsx index 48608047bb..11ec4bad34 100644 --- a/app/soapbox/features/ui/components/modals/hotkeys-modal.tsx +++ b/app/soapbox/features/ui/components/modals/hotkeys-modal.tsx @@ -102,7 +102,7 @@ const HotkeysModal: React.FC = ({ onClose }) => { n - + alt + n diff --git a/app/soapbox/features/ui/util/global-hotkeys.tsx b/app/soapbox/features/ui/util/global-hotkeys.tsx index e54528a588..0a4fbb3bea 100644 --- a/app/soapbox/features/ui/util/global-hotkeys.tsx +++ b/app/soapbox/features/ui/util/global-hotkeys.tsx @@ -49,12 +49,13 @@ const GlobalHotkeys: React.FC = ({ children, node }) => { const handleHotkeyNew = (e?: KeyboardEvent) => { e?.preventDefault(); - if (!node.current) return; - const element = node.current.querySelector('textarea#compose-textarea') as HTMLTextAreaElement; + const element = node.current?.querySelector('textarea#compose-textarea') as HTMLTextAreaElement; if (element) { element.focus(); + } else { + dispatch(openModal('COMPOSE')); } }; diff --git a/app/soapbox/locales/en.json b/app/soapbox/locales/en.json index 7b24fd6109..c5808be641 100644 --- a/app/soapbox/locales/en.json +++ b/app/soapbox/locales/en.json @@ -912,7 +912,7 @@ "keyboard_shortcuts.back": "to navigate back", "keyboard_shortcuts.blocked": "to open blocked users list", "keyboard_shortcuts.boost": "to repost", - "keyboard_shortcuts.compose": "to focus the compose textarea", + "keyboard_shortcuts.compose": "to open the compose textarea", "keyboard_shortcuts.down": "to move down in the list", "keyboard_shortcuts.enter": "to open post", "keyboard_shortcuts.favourite": "to like",