From cb9c855993736a56d55c5b551011c469f22ccd3c Mon Sep 17 00:00:00 2001
From: Calixte Denizet <calixte.denizet@gmail.com>
Date: Wed, 6 Dec 2023 16:10:29 +0100
Subject: [PATCH] [Editor] Avoid to have a color picker for highlighting twice
 in the main toolbar

When opening a pdf from the secondary toolbar, a second color picker is added.
So in order to avoid that, we just stop listening for annotationeditoruimanager
in the toolbar.
---
 web/toolbar.js | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/web/toolbar.js b/web/toolbar.js
index bf437a597..3bf9e3fa9 100644
--- a/web/toolbar.js
+++ b/web/toolbar.js
@@ -121,12 +121,17 @@ class Toolbar {
     this.#bindListeners(options);
 
     if (options.editorHighlightColorPicker) {
-      this.eventBus._on("annotationeditoruimanager", ({ uiManager }) => {
-        this.#setAnnotationEditorUIManager(
-          uiManager,
-          options.editorHighlightColorPicker
-        );
-      });
+      this.eventBus._on(
+        "annotationeditoruimanager",
+        ({ uiManager }) => {
+          this.#setAnnotationEditorUIManager(
+            uiManager,
+            options.editorHighlightColorPicker
+          );
+        },
+        // Once the color picker has been added, we don't want to add it again.
+        { once: true }
+      );
     }
 
     this.reset();