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 181 forks source link

pageViewMode infinite-scroll causes error this.dynamicCSSComponent is undefined or cannot read properties of undefined (reading 'removeScrollbarInInfiniteScrollMode' #2539

Closed JohanHeyvaert closed 1 month ago

JohanHeyvaert commented 1 month ago

Yesterday we updated our packages to angular 18.2.1 and ngx-extended-pdf-viewer 21.3.5 (just now to 21.3.6). In the previous versions pageViewMode infinite-scroll without problems, but now this causes an error:

The document is shown and everything seems to work except for the infinite scroll behaviour: the viewer shows a scrollbar. Without the pageViewMode setting we don't have an error.

We have tried both the stable and the bleeding edge version, same issue.

As we are not doing anything special I don't understand why this works on the example: https://pdfviewer.net/extended-pdf-viewer/infinite-scroll

We don't have the problem with ngx-extended-pdf-viewer versions 20.5.2, 21.0.0, 21.1.0. The issue seems to start in version 21.1.1.

It seems to be caused by this change: https://github.com/stephanrauh/ngx-extended-pdf-viewer/commit/75f2497a87578082846f7e87fee025273f7c4ac4#diff-0d22735be0415662dd0a8a345bd117c5992f317db2da29e67539202efba0f884

But I don't understand why this doesn't work in our application.

Version info

Demo PDF file The problem occurs with all PDF files.

JohanHeyvaert commented 1 month ago

Correction: version 21.1.0 doesn't cause an error but the infinite-scroll is not working. The viewer shows a scrollbar.

stephanrauh commented 1 month ago

Just a wild shot: this is referenced in a Lambda, so maybe it's an undefined pointer when the callback function is invoked.

Can you send me a reproducer? Because, as you said, it works in my demo - and it's hard to fix a bug I don't even see.

JohanHeyvaert commented 1 month ago

Hello Stephan,

Thanks for your response. Here is a minimal application: https://stackblitz.com/edit/stackblitz-starters-rgnasq?file=src%2Fmain.ts So really nothing special.

image

Hopefully you've got an idea? Anyway it's not urgent as our current version is working fine.

Thanks in advance.

JohanHeyvaert commented 1 month ago

In the example I forgot to add a ref to the scss in angular.json but that doesn't matter I suppose. It's present in our project anyway.

stephanrauh commented 1 month ago

It's a JavaScript error message, so most likely it's not caused by SCSS.

stephanrauh commented 1 month ago

I've found and solved the bug. Now I know why it's a good idea to react to changes in ngOnChanges() instead of doing it in a setter of an @Input() attribute.

Be that as it may, version 21.3.7 fixes the bug.

By the way, the bug also showed in the showcase. I found the same error message in the console.

JohanHeyvaert commented 1 month ago

Great! Thanks for the swift resolution. Maybe you could use input signals? (I don't have the code at hand, maybe not appropriate for this case) By the way, I suppose many people already told you, but this is really a fantastic library. Best regards, Johan

Op vr 30 aug 2024 23:11 schreef Stephan Rauh @.***>:

I've found and solved the bug. Now I know why it's a good idea to react to changes in ngOnChanges() instead of doing it in a setter of an @Input() attribute.

Be that as it may, version 21.3.7 fixes the bug.

By the way, the bug also showed in the showcase. I found the same error message in the console.

— Reply to this email directly, view it on GitHub https://github.com/stephanrauh/ngx-extended-pdf-viewer/issues/2539#issuecomment-2322343409, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADI4IMVWK5XLQBHVQVHPC3TZUDNZZAVCNFSM6AAAAABNJ6H2VSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRSGM2DGNBQHE . You are receiving this because you authored the thread.Message ID: @.***>

stephanrauh commented 1 month ago

Thank you very much for your kind words! That's what keeps me going!

At the moment, I aim to be compatible with Angular 16, so I suppose I can't use input signals. Have they been released officially now? Last thing I heard was they're a preview. Generally speaking, I believe signals are a big step into the right direction, so I look forward to using input signals.

JohanHeyvaert commented 1 month ago

I think they are now official. At least in the docs ( https://angular.dev/guide/signals) I don't see anything mentioned any longer about beta or developer preview. I've been using them since angular 15 and they are really great. 🙂

Op vr 30 aug 2024 23:24 schreef Stephan Rauh @.***>:

Thank you very much for your kind words! That's what keeps me going!

At the moment, I aim to be compatible with Angular 16, so I suppose I can't use input signals. Have they been released officially now? Last thing I heard was they're a preview. Generally speaking, I believe signals are a big step into the right direction, so I look forward to using input signals.

— Reply to this email directly, view it on GitHub https://github.com/stephanrauh/ngx-extended-pdf-viewer/issues/2539#issuecomment-2322357638, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADI4IMRNL2DJICRV6NNUZPLZUDPIDAVCNFSM6AAAAABNJ6H2VSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRSGM2TONRTHA . You are receiving this because you authored the thread.Message ID: @.***>

JohanHeyvaert commented 1 month ago

Correction, since v16 😁

stephanrauh commented 1 month ago

Yeah, version 15 puzzled me - Signals are the reason why I dropped Angular 15 support. :)