Skip to content

Commit

Permalink
restore selection (#2577)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rain-Zheng authored Apr 16, 2024
1 parent 25f0296 commit d598652
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ export class EditPlugin implements EditorPlugin {

if (handled) {
rawEvent.preventDefault();

// Restore the selection to avoid the cursor jump issue
// See: https://issues.chromium.org/issues/330596261
const selection = editor.getDOMSelection();
const doc = this.editor?.getDocument();
doc?.defaultView?.requestAnimationFrame(() => {
if (this.editor) {
this.editor.setDOMSelection(selection);
}
});
}
}
}

0 comments on commit d598652

Please sign in to comment.