Fix focus lost after adding note if non-sticky (#1523)

This commit is contained in:
Henrik Giesel 2021-12-03 12:41:12 +01:00 committed by GitHub
parent ae29c8c333
commit d0c6f0d7ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -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 { saveSelection, restoreSelection } from "../domlib/location";
import { on, preventDefault } from "../lib/events";
import { caretToEnd } from "../lib/dom";
import { registerShortcut } from "../lib/shortcuts";
export let nodes: Writable<DocumentFragment>;
@ -29,7 +30,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
"focus",
() => {
if (location) {
restoreSelection(editable, location);
try {
restoreSelection(editable, location);
} catch {
caretToEnd(editable);
}
}
},
{ once: true },

View file

@ -57,6 +57,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
codeMirror.setSelections(ranges);
} catch {
ranges = null;
codeMirror.setCursor(codeMirror.lineCount(), 0);
}
}
unsubscribe();