Skip to content

Commit ff6c5aa

Browse files
committed
Markdown Editor: Fixed scroll jump on image upload
For #5384
1 parent 980a684 commit ff6c5aa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

resources/js/markdown/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,12 @@ export class Actions {
445445
selectionRange = selectionRange || this.#getSelectionRange();
446446
const newDoc = this.editor.cm.state.toText(text);
447447
const newSelectFrom = Math.min(selectionRange.from, newDoc.length);
448+
const scrollTop = this.editor.cm.scrollDOM.scrollTop;
448449
this.#dispatchChange(0, this.editor.cm.state.doc.length, text, newSelectFrom);
449450
this.focus();
451+
window.requestAnimationFrame(() => {
452+
this.editor.cm.scrollDOM.scrollTop = scrollTop;
453+
});
450454
}
451455

452456
/**

0 commit comments

Comments
 (0)