Skip to content

Commit

Permalink
[Editor] Avoid to scroll when an annotation is commited (fixes issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Dec 17, 2022
1 parent 1ab711e commit a84d14b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/display/editor/freetext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions src/display/editor/ink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit a84d14b

Please sign in to comment.