Merge pull request #15849 from calixteman/15744

[Editor] Avoid to scroll when an annotation is commited (fixes issue #15744)
This commit is contained in:
calixteman 2022-12-17 16:16:36 +01:00 committed by GitHub
commit dd96ee1512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 */