mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Fix focus lost after adding note if non-sticky (#1523)
This commit is contained in:
parent
ae29c8c333
commit
d0c6f0d7ba
2 changed files with 7 additions and 1 deletions
|
@ -7,6 +7,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import { updateAllState } from "../components/WithState.svelte";
|
import { updateAllState } from "../components/WithState.svelte";
|
||||||
import { saveSelection, restoreSelection } from "../domlib/location";
|
import { saveSelection, restoreSelection } from "../domlib/location";
|
||||||
import { on, preventDefault } from "../lib/events";
|
import { on, preventDefault } from "../lib/events";
|
||||||
|
import { caretToEnd } from "../lib/dom";
|
||||||
import { registerShortcut } from "../lib/shortcuts";
|
import { registerShortcut } from "../lib/shortcuts";
|
||||||
|
|
||||||
export let nodes: Writable<DocumentFragment>;
|
export let nodes: Writable<DocumentFragment>;
|
||||||
|
@ -29,7 +30,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
"focus",
|
"focus",
|
||||||
() => {
|
() => {
|
||||||
if (location) {
|
if (location) {
|
||||||
restoreSelection(editable, location);
|
try {
|
||||||
|
restoreSelection(editable, location);
|
||||||
|
} catch {
|
||||||
|
caretToEnd(editable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ once: true },
|
{ once: true },
|
||||||
|
|
|
@ -57,6 +57,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
codeMirror.setSelections(ranges);
|
codeMirror.setSelections(ranges);
|
||||||
} catch {
|
} catch {
|
||||||
ranges = null;
|
ranges = null;
|
||||||
|
codeMirror.setCursor(codeMirror.lineCount(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
|
|
Loading…
Reference in a new issue