mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Merge pull request #1272 from hgiesel/clickondiv
Move selection into editable, if it's not there after focus
This commit is contained in:
commit
972deba041
1 changed files with 10 additions and 0 deletions
|
@ -1,6 +1,10 @@
|
|||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
/* eslint
|
||||
@typescript-eslint/no-non-null-assertion: "off",
|
||||
*/
|
||||
|
||||
import { enableButtons, disableButtons } from "./toolbar";
|
||||
import type { EditingArea } from "./editing-area";
|
||||
|
||||
|
@ -10,6 +14,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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue