Fix focus change on tab
This commit is contained in:
parent
6e907fd8b6
commit
594fc9bebd
@ -2,8 +2,8 @@
|
|||||||
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
||||||
|
|
||||||
let currentField: EditingContainer | null = null;
|
let currentField: EditingContainer | null = null;
|
||||||
let changeTimer = null;
|
let changeTimer: number | null = null;
|
||||||
let currentNoteId = null;
|
let currentNoteId: number | null = null;
|
||||||
|
|
||||||
declare interface String {
|
declare interface String {
|
||||||
format(...args: string[]): string;
|
format(...args: string[]): string;
|
||||||
@ -254,6 +254,7 @@ function onFocus(evt: FocusEvent): void {
|
|||||||
// anki window refocused; current element unchanged
|
// anki window refocused; current element unchanged
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
elem.focusEditingArea();
|
||||||
currentField = elem;
|
currentField = elem;
|
||||||
pycmd(`focus:${currentFieldOrdinal()}`);
|
pycmd(`focus:${currentFieldOrdinal()}`);
|
||||||
enableButtons();
|
enableButtons();
|
||||||
@ -307,12 +308,12 @@ function onPaste(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function caretToEnd(): void {
|
function caretToEnd(): void {
|
||||||
const r = document.createRange();
|
const range = document.createRange();
|
||||||
r.selectNodeContents(currentField);
|
range.selectNodeContents(currentField.editingArea);
|
||||||
r.collapse(false);
|
range.collapse(false);
|
||||||
const s = currentField.getSelection();
|
const selection = currentField.getSelection();
|
||||||
s.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
s.addRange(r);
|
selection.addRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBlur(): void {
|
function onBlur(): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user