Skip to content

Commit 00f94a9

Browse files
committed
possibly fix #6803 -- wywiwg markdown: "Out of control cursor jumps to previous position in the sentence while typing"
- i can't reproduce this bug on purpose or ever in dev env, so I will reopen this if I hit it in production (where I do hit it) - logically it would make sense this could be the cause
1 parent 6831ac6 commit 00f94a9

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/packages/frontend/editors/slate/edit-bar/list-edit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const ListEdit: React.FC<Props> = ({ listProperties, editor }) => {
122122
style={{ color: "#666" }}
123123
onClick={() => {
124124
moveListItemUp(editor);
125-
ReactEditor.focus(editor);
125+
ReactEditor.focus(editor, false, true);
126126
}}
127127
>
128128
<Icon name={"arrow-up"} />
@@ -137,7 +137,7 @@ export const ListEdit: React.FC<Props> = ({ listProperties, editor }) => {
137137
style={{ color: "#666" }}
138138
onClick={() => {
139139
moveListItemDown(editor);
140-
ReactEditor.focus(editor);
140+
ReactEditor.focus(editor, false, true);
141141
}}
142142
>
143143
<Icon name={"arrow-down"} />

src/packages/frontend/editors/slate/elements/code-block/insert-bar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ export default function InsertBar({ editor, element, info, above }) {
3333
path = Path.next(path);
3434
}
3535
Transforms.insertNodes(editor, node, { at: path });
36-
ReactEditor.focus(editor, true);
36+
ReactEditor.focus(editor, true, true);
3737
if (path) {
3838
setTimeout(() => {
3939
const sel = {
4040
anchor: { path: path!, offset: 0 },
4141
focus: { path: path!, offset },
4242
};
4343
Transforms.setSelection(editor, sel);
44-
ReactEditor.focus(editor, true);
44+
ReactEditor.focus(editor, true, true);
4545
}, 50);
4646
}
4747
};

src/packages/frontend/editors/slate/slate-react/plugin/react-editor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ export const ReactEditor = {
142142
force: boolean = false,
143143
preserveSelection: boolean = false,
144144
): void {
145-
console.trace("focus!", { force });
146145
const { selection } = editor;
147146
const el = ReactEditor.toDOMNode(editor, editor);
148147
IS_FOCUSED.set(editor, true);
@@ -157,7 +156,6 @@ export const ReactEditor = {
157156
el.focus({ preventScroll: true });
158157
}
159158
if (selection != null && preserveSelection) {
160-
console.log("setting selection", { selection });
161159
// I've changed the focus method to optionally preserve the selection if there is one.
162160
// However, doing this when not needed may be the cause of
163161
// https://github.com/sagemathinc/cocalc/issues/6803

0 commit comments

Comments
 (0)