Skip to content

Reload/navigation confirmation on PDFs with forms #2691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rms2219 opened this issue Dec 16, 2024 · 3 comments
Open

Reload/navigation confirmation on PDFs with forms #2691

rms2219 opened this issue Dec 16, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@rms2219
Copy link

rms2219 commented Dec 16, 2024

When there is a form on a PDF, and the user interacts with the PDF, they will always be prompted if they haven't downloaded the PDF prior to reloading or navigating away regardless of any form values changing.

Maybe? There is no form on this sample PDF so I'm not sure if it's an issue w/ the library or not.

I opened the PDF in Firefox, which uses the Mozilla PDF.js, and the issue does not appear there.

Yes

Describe the bug

  1. Load any PDF that has a form on it (use default options)
  2. Click on a form field, but make no changes/edits
  3. Reload or navigate away from page
  4. Observe confirmation notifying that changes have not been saved.

No changes have actually been made, so there should be no prompt. Additional unrelated changes (e.g. change the zoom of the PDF) will also trigger this same condition.

Ideally, there should be an option that disables any such prompt, without explicitly disabling the form. For our use case, we have no need to ensure the user wants to save any changes to the PDF. Our users will never be editing forms anyway, but we don't want to explicitly disable the form in the off-chance that they would like to edit and download a local copy. It should be noted that even using [disableForms] option still presents this confirmation.

Version info

  • 22.0.1

Example PDF: https://www.signify.com/api/assets/v1/file/Signify/content/a654757c91404dbf8360ac8b0104206e/Swan-LED-Pendant--CXF4----Spec-Sheet--G3-.pdf

@rms2219
Copy link
Author

rms2219 commented Dec 16, 2024

To add to this, I found that if I handle the onPageRendered event, I can do this:

pageView.annotationLayer.annotationStorage.resetModified();

This allows me to proceed without the prompt to save changes. If I do, in fact, set a form field and try to reload, I'll still be prompted.

@stephanrauh
Copy link
Owner

The key point is that the - usually desired - confirmation dialog appears when you click a field without changing anything.

At the moment, I can't say much about it. As far as I can see, that doesn't happen on https://pdfviewer.net/extended-pdf-viewer/forms. Can you confirm that? If so, the problem might be your PDF file. It's possible that the file contains some magic that makes the PDF viewer (and the browser) believe you've edited the form.

Note that this is merely a first assessment. I haven't examined your PDF file yet (it's late in the evening), but maybe me thoughts already help you.

@stephanrauh stephanrauh self-assigned this Dec 18, 2024
@stephanrauh stephanrauh added the bug Something isn't working label Dec 18, 2024
@rms2219
Copy link
Author

rms2219 commented Dec 18, 2024

Can you confirm that?

I cannot confirm that. In your forms sample, simply loading the page, scrolling the PDF and attempting to reload will cause this confirmation dialog. I did not interact with a form element at all. This was done in Firefox.

I've attached a screen recording for you to see my actions.

Screen.Recording.2024-12-18.mov

As an aside, I'm no longer to load that example page in Brave, yet I could yesterday:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants