Merge pull request #19202 from calixteman/avoid_to_lose_focus
[Editor] Don't commit the current drawing while zooming
This commit is contained in:
commit
898be9ef5e
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -140,6 +140,7 @@ class AnnotationEditorLayerBuilder {
|
||||
if (!this.div) {
|
||||
return;
|
||||
}
|
||||
this.annotationEditorLayer.pause(/* on */ true);
|
||||
this.div.hidden = true;
|
||||
}
|
||||
|
||||
@ -148,6 +149,7 @@ class AnnotationEditorLayerBuilder {
|
||||
return;
|
||||
}
|
||||
this.div.hidden = false;
|
||||
this.annotationEditorLayer.pause(/* on */ false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user