mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
47.96k stars 9.92k forks source link

[Bug]: Add Remove Event Listeners for Events #18633

Closed ademyalcin27 closed 3 weeks ago

ademyalcin27 commented 3 weeks ago

Attach (recommended) or Link to PDF file

in tools.js _keyboardManager methods is blocking backspace if the input type is not text and number (Blow Code, when I use email as input type, I cant use backspace. there should removeEventListener. Can you please look at this. I have added a video that clearly shows the situation.

 const textInputChecker = (_self, { target: el }) => {
      if (el instanceof HTMLInputElement) {
        const { type } = el;
        return type !== "text" && type !== "number";
      }
      return true;
    };

Web browser and its version

Version 127.0.6533.120 (Official Build) (x86_64)

Operating system and its version

mac

PDF.js version

4.2.67

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

1- Add Input field which is type email or tel 2- type something 3- use backspace button.(its not working)

What is the expected behavior?

when you press the backspace button it should work for other input types.the

What went wrong?

https://github.com/user-attachments/assets/5d5d35a0-d8e8-46a3-9244-ddb50a16cd8e

Link to a viewer

No response

Additional context

No response

ademyalcin27 commented 3 weeks ago

What infirmation request? @Snuffleupagus

Snuffleupagus commented 3 weeks ago

Attach (recommended) or Link to PDF file

in tools.js _keyboardManager methods is blocking backspace if the input type is not text and number (Blow Code, when I use email as input type, I cant use backspace. there should removeEventListener. Can you please look at this. I have added a video that clearly shows the situation.

 const textInputChecker = (_self, { target: el }) => {
      if (el instanceof HTMLInputElement) {
        const { type } = el;
        return type !== "text" && type !== "number";
      }
      return true;
    };

None of this context seems relevant under a heading called Attach (recommended) or Link to PDF file.

PDF.js version

4.2.67

That version is no longer supported, please find the latest releases at https://mozilla.github.io/pdf.js/getting_started/#download

Steps to reproduce the problem

1- Add Input field which is type email or tel 2- type something 3- use backspace button.(its not working)

How can this be reproduced in https://mozilla.github.io/pdf.js/web/viewer.html, since that's not at all obvious?

It sounds like your issue is with a custom implementation, hence please see https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md (emphasis mine):

If you are developing a custom solution, first check the examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare a short well-documented example that demonstrates the problem and make it accessible online on your website, JS Bin, GitHub, etc. before opening a new issue or contacting us in the Matrix room -- keep in mind that just code snippets won't help us troubleshoot the problem.

timvandermeij commented 3 weeks ago

Closing until the information requested above is provided; this should at the very least get clear steps to reproduce using the latest PDF.js version at https://mozilla.github.io/pdf.js/web/viewer.html for us to be able to help.

ademyalcin27 commented 2 weeks ago

I found the problem, when annotationEditorMode is not None or Disabled, pdfjs-lib listening all keydown events except input type text and tel