How to disable multiselect annotation option - just select multiple selection at once

Hi all,

I would like to disable option for a user to select multiple annotations at once, which would open notes panel with check boxes.


(Here I’ve hidden checkboxes manually)

I’d like either to disable this tool, or to fetch the event of this bottom right (X) button that cancel multiselect mode.

Thanks!

Hi @mindlessrocket,

Thanks for reaching out to WebViewer Support!

You can manually disable the multi-select mode by clicking the checkbox near the top of the comments panel as illustrated in the image below.

Screenshot 2023-02-06 at 4.54.26 PM

Or you can disable the button from the UI with the UI.disableElements API:

instance.UI.disableElements(['multiSelectModeButton']);

Let me know how this works for you!

Adam Sinclair
Web Developer
PDFTron

We don’t have an official API to disable multi-select mode. But you can listen to the annotationSelect event and disable multi-select mode by querying the DOM and clicking the ‘X’ button. The snippet below should help you get started:

instance.Core.annotationManager.addEventListener('annotationSelected', (annotationList, action) => {
  if (action === 'selected' && annotationList.length > 1) {

    // Slight delay to give React time to re-render the disable button.
    setTimeout(() => {
      const disableMultiSelectButton = document.querySelector('div.multi-select-footer div.close-container div.close-icon-container');    
      if (disableMultiSelectButton) {
        disableMultiSelectButton.click();
      }
    }, 100);
  }
});

Let me know if this helps!

Adam

1 Like

Hello Adam!

Thanks, works nice!

1 Like