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

Merge pull request #19202 from calixteman/avoid_to_lose_focus

[Editor] Don't commit the current drawing while zooming
This commit is contained in:
calixteman 2024-12-09 19:00:26 +01:00 committed by GitHub
commit 898be9ef5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View file

@ -76,6 +76,8 @@ class AnnotationEditorLayer {
#drawingAC = null;
#focusedElement = null;
#textLayer = null;
#textSelectionAC = null;
@ -811,6 +813,7 @@ class AnnotationEditorLayer {
"blur",
({ relatedTarget }) => {
if (relatedTarget && !this.div.contains(relatedTarget)) {
this.#focusedElement = null;
this.commitOrRemove();
}
},
@ -819,6 +822,22 @@ class AnnotationEditorLayer {
this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);
}
pause(on) {
if (on) {
const { activeElement } = document;
if (this.div.contains(activeElement)) {
this.#focusedElement = activeElement;
}
return;
}
if (this.#focusedElement) {
setTimeout(() => {
this.#focusedElement?.focus();
this.#focusedElement = null;
}, 0);
}
}
endDrawingSession(isAborted = false) {
if (!this.#drawingAC) {
return null;
@ -826,6 +845,7 @@ class AnnotationEditorLayer {
this.#uiManager.setCurrentDrawingSession(null);
this.#drawingAC.abort();
this.#drawingAC = null;
this.#focusedElement = null;
return this.#currentEditorType.endDrawing(isAborted);
}