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:
parent
30dbacc1a1
commit
421edb6691
@ -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 });
|
||||
|
Loading…
Reference in New Issue
Block a user