SelectionTextMode can't be toggle (in mobile)

Which product are you using?

PDF.js Express

PDF.js Express Version

8.1.0

Detailed description of issue
when i click selectTextButton, the viewer turns to text selection mode, but when i click the button again, text selection mode can’t be toggle, so when i touch the mobile screen, the pdf text will be selected.

Expected behaviour
text selection mode should be toggle when i click selectionTextButton

Does your issue happen with every document, or just one?
it happens anyway when in mobile

Link to document

Code snippet

          WebViewer(
            {
              licenseKey: 'zSbyd7VXHHiO0AP6DxNO',
              path: '/webviewer/lib',
              initialDoc: pdfUri,
              css: '/pdf.css',
              disabledElements: [
                'leftPanelTabs',
                'menuButton',
                'panToolButton',
                'viewControlsButton',
                'selectToolButton',
              ],
            },
            viewerRef.current
          ).then((instance: any) => {
            // now you can access APIs through the WebViewer instance
            const { Core, UI } = instance
            console.log('instance', instance)
            // adding an event listener for when a document is loaded
            Core.documentViewer.addEventListener('documentLoaded', () => {
              UI.setSideWindowVisibility(!isMobile)
            })
            // adding an event listener for when the page number has changed
            // Core.documentViewer.addEventListener(
            //   'pageNumberUpdated',
            //   (pageNumber: number) => {
            //     console.log(`Page number is: ${pageNumber}`)
            //   }
            // )
            Core.documentViewer.addEventListener('mouseLeftUp', (e: any) => {
              // !!selectTxt.length && instance.UI.openElements([modalOptions.dataElement])
              instance.UI.textPopup.update(textPopupButtons)
            })
            Core.documentViewer.addEventListener(
              'textSelected',
              (quads: any, selectedStr: string, pageNumber: number) => {
                selectedText = selectedStr
              }
            )

            // adds a button to the header that on click sets the page to the next page
            if (showCupture && !isMobile) {
              UI.setHeaderItems((header: any) => {
                header.get('searchButton')
                header.insertBefore({
                  type: 'actionButton',
                  img: iconFullSize,
                  onClick: () => {
                    onCupture()
                  },
                })
              })
            }
          })

Hi there,

Could you please clarify what you mean by selectTextButton?
Are you able to reproduce this in the demo? PDF.js Viewer Demo | PDF.js Express

Best regards,
Kevin Kim

This is the button, which can’t be toggle. Neither can the demo you gave.

please help me solve the problem, it‘s important to me.

Thanks.

I am still unable to see that button on the demo:

However, if you need to enable that button, you can do this via

instance.UI.setToolMode(Tools.ToolNames.TEXT_SELECT)

Best regards,
Kevin Kim

Thank you for your reply, but it still doesn’t solve my problem.

  1. When you switch to iPhone mode (the picture shows that you were in iPad mode), you can see the button.
  2. What I want is not just to enable the button, but to disable the button when I click it again (it cannot be disabled once it is turned on).

Hi there,

I tried the different iPhone options but still didn’t see the icon

However, if you would like to toggle the button, you may need to override the default behaviour and deselect the tool via switchOut:
https://pdfjs.express/api/Core.Tools.Tool.html#switchOut__anchor

Best regards,
Kevin Kim