1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

[Editor] Unselect correctly removed editors

- After undoing a deletion of several editors, they appeared to be selected (they had a red border)
when in fact they were not, consequently, this patch aims to remove the selectedEditor class when
an editor is removed;
- Add a test with some ink editors.
This commit is contained in:
Calixte Denizet 2022-07-22 12:13:47 +02:00
parent 6138e16ce2
commit 5bbe0d0782
6 changed files with 127 additions and 31 deletions

View file

@ -416,6 +416,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.moveDivInDOM(this);
// 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();
}
/** @inheritdoc */

View file

@ -709,9 +709,7 @@ class AnnotationEditorUIManager {
*/
removeEditor(editor) {
this.#allEditors.delete(editor.id);
if (this.hasSelection) {
this.#selectedEditors.delete(editor);
}
this.unselect(editor);
}
/**
@ -962,6 +960,15 @@ class AnnotationEditorUIManager {
* Unselect all the selected editors.
*/
unselectAll() {
if (this.#activeEditor) {
// An editor is being edited so just commit it.
this.#activeEditor.commitOrRemove();
return;
}
if (this.#selectEditors.size === 0) {
return;
}
for (const editor of this.#selectedEditors) {
editor.unselect();
}