Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Slightly postpone the move in the DOM in order to not block the UI (bug 1854991) #17031

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/display/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class AnnotationEditor {

#isInEditMode = false;

#moveInDOMTimeout = null;

_initialOptions = Object.create(null);

_uiManager = null;
Expand Down Expand Up @@ -1046,7 +1048,16 @@ class AnnotationEditor {
}

moveInDOM() {
this.parent?.moveEditorInDOM(this);
// Moving the editor in the DOM can be expensive, so we wait a bit before.
// It's important to not block the UI (for example when changing the font
// size in a FreeText).
if (this.#moveInDOMTimeout) {
clearTimeout(this.#moveInDOMTimeout);
}
this.#moveInDOMTimeout = setTimeout(() => {
this.#moveInDOMTimeout = null;
this.parent?.moveEditorInDOM(this);
}, 0);
}

_setParentAndPosition(parent, x, y) {
Expand Down Expand Up @@ -1253,6 +1264,10 @@ class AnnotationEditor {
this.#altTextButton?.remove();
this.#altTextButton = null;
this.#altTextTooltip = null;
if (this.#moveInDOMTimeout) {
clearTimeout(this.#moveInDOMTimeout);
this.#moveInDOMTimeout = null;
}
}

/**
Expand Down