stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
474 stars 182 forks source link

Formatted text field values cleared out of angular form data when leaving a field. #2133

Open claymeisman opened 8 months ago

claymeisman commented 8 months ago

Describe the bug Open/Create a PDF with field that as the formatting option enabled, like money. There just has to be one field to break all fields.

When using the text selection tool (Hand tool is a different bug) open the pdf:

  1. Enter a value on the first field.
  2. Navigate away by pressing tab or click on the white space of the document.
  3. Review the answers sent to angular. Notice they are cleared out/not in sync?

Version info

Demo PDF file FormattedTest.pdf

stephanrauh commented 8 months ago

Without having looked at your bug yet: thank you so much for providing a reproducer! My gut feeling is you've reported a challenging bug, so I happily accept every help I can get!

claymeisman commented 8 months ago

This is the fix I am doing in the mean time. Personal fork

I went back and forth on where to put the check for the formattedValue field. From should it be sent in the first place to accounting for it at just the place I am seeing an issue.

I opted for my specific scenario fix.

claymeisman commented 8 months ago

Basically, there is an extra call to updateAngularFormValue being generated when there are formatted fields. And if the leaving field does not have formatting it is making that call with a null formattedValue field. So, to me that is the bug, but that is in the pdfjs code, and I was leery of modifying that cause I did not know where or how that was being made.

stephanrauh commented 4 months ago

Maybe I solved your bug today. At the moment, I'm trying to work my way through the tickets that piled up during my vacations, so I didn't run a test yet, but it reminds me of a bug I solved with version 20.2.0.