From aa3ba383926eb0c65c7b5c085354a1c66dd9c578 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 6 Mar 2021 17:57:04 +0100 Subject: [PATCH] Do not execute caretToEnd when Alt-tabbing back to application --- ts/editor/focusHandlers.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ts/editor/focusHandlers.ts b/ts/editor/focusHandlers.ts index b6cfb5c7fdd..abc7095bb73 100644 --- a/ts/editor/focusHandlers.ts +++ b/ts/editor/focusHandlers.ts @@ -20,7 +20,6 @@ function focusField(field: EditingArea) { field.focusEditable(); bridgeCommand(`focus:${field.ord}`); enableButtons(); - caretToEnd(field); } // For distinguishing focus by refocusing window from deliberate focus @@ -31,10 +30,14 @@ export function onFocus(evt: FocusEvent): void { const previousFocus = evt.relatedTarget as EditingArea; if ( - previousFocus === previousActiveElement || - !(previousFocus instanceof EditingArea) + !(previousFocus instanceof EditingArea) || + previousFocus === previousActiveElement ) { focusField(currentField); + + if (previousFocus) { + caretToEnd(currentField); + } } }