From d11d66ee79cc1a32db83bd3ac52809dd203ee66a Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 3 Jul 2021 01:00:52 +0200 Subject: [PATCH] Move selection into editable, if it's not there after focus --- ts/editor/focus-handlers.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ts/editor/focus-handlers.ts b/ts/editor/focus-handlers.ts index e72595d38..ee80a92ff 100644 --- a/ts/editor/focus-handlers.ts +++ b/ts/editor/focus-handlers.ts @@ -10,6 +10,12 @@ import { bridgeCommand } from "./lib"; export function onFocus(evt: FocusEvent): void { const currentField = evt.currentTarget as EditingArea; currentField.focus(); + + if (currentField.shadowRoot!.getSelection()!.anchorNode === null) { + // selection is not inside editable after focusing + currentField.caretToEnd(); + } + bridgeCommand(`focus:${currentField.ord}`); enableButtons(); }