1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00

Desktop: Fixes #11485: Fix pressing enter during composition in the title input moves focus (#11491)

This commit is contained in:
Henry Heino 2024-12-12 13:30:20 -08:00 committed by GitHub
parent 30dbacc1a1
commit 421edb6691
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,7 +85,12 @@ export default function NoteTitleBar(props: Props) {
const onTitleKeydown: React.KeyboardEventHandler<HTMLInputElement> = 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 });