From 421edb66910697a1b581809f59a39a2f00906e97 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:30:20 -0800 Subject: [PATCH] Desktop: Fixes #11485: Fix pressing enter during composition in the title input moves focus (#11491) --- .../app-desktop/gui/NoteEditor/NoteTitle/NoteTitleBar.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/app-desktop/gui/NoteEditor/NoteTitle/NoteTitleBar.tsx b/packages/app-desktop/gui/NoteEditor/NoteTitle/NoteTitleBar.tsx index a878fa7e0..b9e2b49c8 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteTitle/NoteTitleBar.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteTitle/NoteTitleBar.tsx @@ -85,7 +85,12 @@ export default function NoteTitleBar(props: Props) { const onTitleKeydown: React.KeyboardEventHandler = useCallback((event) => { const titleElement = event.currentTarget; const selectionAtEnd = titleElement.selectionEnd === titleElement.value.length; - if ((event.key === 'ArrowDown' && selectionAtEnd) || (event.key === 'Enter' && !event.shiftKey)) { + const isNavigationShortcut = (event.key === 'ArrowDown' && selectionAtEnd) || (event.key === 'Enter' && !event.shiftKey); + const composing = event.nativeEvent.isComposing; + + // Don't change focus if the navigation shortcut is fired during composition. See + // https://github.com/laurent22/joplin/issues/11485. + if (!composing && isNavigationShortcut) { event.preventDefault(); const moveCursorToStart = event.key === 'ArrowDown'; void CommandService.instance().execute('focusElement', 'noteBody', { moveCursorToStart });