mirror of
https://github.com/laurent22/joplin.git
synced 2026-06-18 20:16:34 +02:00
Desktop: Fixes #11485: Fix pressing enter during composition in the title input moves focus (#11491)
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user