How hide annotation when toolbar group changed

Which product are you using?
PDF.js Express Plus

PDF.js Express Version
8.3.2

Detailed description of issue
i want to toggle annotations appearance when change toolbar group (view - annotation- …)
{Description here}

Expected behaviour
{Provide a screenshot or description of the expected behaviour}

Does your issue happen with every document, or just one?
every document
{Answer here}

Link to document
{Provide a link to the document in question if possible}

Code snippet
{Provide a relevant code snippet}

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi There, thanks for your question.

Could you please provide more information about this use case?

To begin helping you below is a code of how you can listen to the event of changing the toolbar group. This will return which Toolbar group the user had chosen. I also added the code of how to get the list of annotations.

WebViewer({
...options
}).then(instance => {
...
   const { annotationManager } = instance.Core;

   const UIEvents = instance.UI.Events;
   
   instance.UI.addEventListener(UIEvents.TOOLBAR_GROUP_CHANGED, e => {
     const currentToolbarGroup = e.detail;
     // Toolbar group choosed
     console.log(currentToolbarGroup);
    
     // Annotations list in the moment of the toolbar group change
     const annotationsList = annotationManager.getAnnotationsList();
     console.log(annotationsList);
  });
})

You can use the hideAnnotations API to hide a list of annotations.

Please let me know if this helps.

Thanks,
Dandara