[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("blur", this.#boundEditorDivBlur);
this.editorDiv.removeEventListener("input", this.#boundEditorDivInput); 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
// On Chrome, the focus is given to <body> when contentEditable is set to // false, hence we focus the div.
// false, hence we focus the div. this.div.focus({
this.div.focus(); preventScroll: true /* See issue #15744 */,
} });
// In case the blur callback hasn't been called. // In case the blur callback hasn't been called.
this.isEditing = false; 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 // When commiting, the position of this editor is changed, hence we must
// move it to the right position in the DOM. // move it to the right position in the DOM.
this.parent.moveEditorInDOM(this); this.parent.moveEditorInDOM(this);
if (this.pageIndex === this._uiManager.currentPageIndex) { this.div.focus({
// After the div has been moved in the DOM, the focus may have been stolen preventScroll: true /* See issue #15744 */,
// by document.body, hence we just keep it here. });
this.div.focus();
}
} }
/** @inheritdoc */ /** @inheritdoc */