1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

[Editor] Highlight must keep selected after the document has been scrolled

This commit is contained in:
Calixte Denizet 2023-12-05 23:22:35 +01:00
parent c0436013a0
commit 621b7af60d
2 changed files with 65 additions and 0 deletions

View file

@ -252,12 +252,21 @@ class HighlightEditor extends AnnotationEditor {
}
setParent(parent) {
let mustBeSelected = false;
if (this.parent && !parent) {
this.#cleanDrawLayer();
} else if (parent) {
this.#addToDrawLayer(parent);
// If mustBeSelected is true it means that this editor was selected
// when its parent has been destroyed, hence we must select it again.
mustBeSelected =
!this.parent && this.div?.classList.contains("selectedEditor");
}
super.setParent(parent);
if (mustBeSelected) {
// We select it after the parent has been set.
this.select();
}
}
#cleanDrawLayer() {