mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Move selection into editable, if it's not there after focus
This commit is contained in:
parent
c01c4b642b
commit
d11d66ee79
1 changed files with 6 additions and 0 deletions
|
@ -10,6 +10,12 @@ import { bridgeCommand } from "./lib";
|
||||||
export function onFocus(evt: FocusEvent): void {
|
export function onFocus(evt: FocusEvent): void {
|
||||||
const currentField = evt.currentTarget as EditingArea;
|
const currentField = evt.currentTarget as EditingArea;
|
||||||
currentField.focus();
|
currentField.focus();
|
||||||
|
|
||||||
|
if (currentField.shadowRoot!.getSelection()!.anchorNode === null) {
|
||||||
|
// selection is not inside editable after focusing
|
||||||
|
currentField.caretToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
bridgeCommand(`focus:${currentField.ord}`);
|
bridgeCommand(`focus:${currentField.ord}`);
|
||||||
enableButtons();
|
enableButtons();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue