[Editor] Avoid to scroll when an annotation is commited (fixes issue #15744)

This commit is contained in:
Calixte Denizet 2022-12-17 13:48:19 +01:00
parent 1ab711e2ac
commit a84d14b382
2 changed files with 8 additions and 10 deletions

View File

@ -252,11 +252,11 @@ class FreeTextEditor extends AnnotationEditor {
this.editorDiv.removeEventListener("blur", this.#boundEditorDivBlur);
this.editorDiv.removeEventListener("input", this.#boundEditorDivInput);
if (this.pageIndex === this._uiManager.currentPageIndex) {
// On Chrome, the focus is given to <body> when contentEditable is set to
// false, hence we focus the div.
this.div.focus();
}
// On Chrome, the focus is given to <body> when contentEditable is set to
// false, hence we focus the div.
this.div.focus({
preventScroll: true /* See issue #15744 */,
});
// In case the blur callback hasn't been called.
this.isEditing = false;

View File

@ -517,11 +517,9 @@ class InkEditor extends AnnotationEditor {
// When commiting, the position of this editor is changed, hence we must
// move it to the right position in the DOM.
this.parent.moveEditorInDOM(this);
if (this.pageIndex === this._uiManager.currentPageIndex) {
// After the div has been moved in the DOM, the focus may have been stolen
// by document.body, hence we just keep it here.
this.div.focus();
}
this.div.focus({
preventScroll: true /* See issue #15744 */,
});
}
/** @inheritdoc */