JavaScript error when using the PDF Viewer - Uncaught TypeError Cannot read properties of null (reading 'getBoundingClientRect')

Hi,

I don't know how to reproduce precisely the bug, but when navigating from a page (WASM) with a PDF Viewer component, I sometimes have a JavaScript error that occurs every milliseconds and never stops.


Here is the error : 

Uncaught TypeError: Cannot read properties of null (reading 'getBoundingClientRect')


It mentions this code in the minified syncfusion-blazor-spdfviewer.min.js :

(!sf.base.Browser.isDevice || this.enableDesktopMode) && this.toolbarModule && this.viewerBase.navigationPane && this.enableNavigationToolbar) {

                        var r = 0;

                        i = setInterval((function() {

                            var e = t.element.querySelector(".e-pv-toolbar").getBoundingClientRect().height;

                            r++,

                            (e <= 200 || r >= 5) && (t.viewerBase.navigationPane.adjustPane(),

                            i && (clearInterval(i),

                            i = null))

                        }

                        ), 100)

                    }



Please check if you can add a condition before calling getBoundingClientRect().


Regards.


3 Replies 1 reply marked as answer

VS Venkada Subramanian Durai Syncfusion Team June 4, 2025 01:39 PM UTC

Hi Julien Barach,

Thank you for the update. We were able to reproduce the reported issue "Exception throws when suddenly navigate away from PDF Viewer in WASM". We suspect this to be a defect and will perform further analysis. We will update you with more details by June 9, 2025.


Regards,

Venkada Subramanian Durai



VS Venkada Subramanian Durai Syncfusion Team June 9, 2025 11:04 AM UTC

Hi Julien Barach,

Thank you for your patience. We have confirmed the issue "Exception throws when suddenly navigate away from PDF Viewer in WASM" and logged it as a defect. 

We will include the fix in our weekly NuGet release, which is estimated to be available on July 1,2025.

Feedback: Exception throws when suddenly navigate away from PDF Viewer in WASM

 

Disclaimer: "Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization."




PA Priyadharshini Annamalai Syncfusion Team July 2, 2025 12:49 PM UTC

Hi Julien Barach,


Thank you for your patience. We have fixed the reported issue "Exception throws when suddenly navigate away from PDF Viewer in WASM" and the fix for the reported issue was included in our latest weekly release v30.1.38. Kindly upgrade to that version to get the issue resolved.

 

Root cause: Sudden navigation of component when the toolbarContainer is not created then accessing the toolbarContainer.getBoundingClientRect() cause exception

 

Solution: Added proper null check before accessing the toolbarContainer

Packages:

 

 

Blazor NextGen

https://www.nuget.org/packages/Syncfusion.Blazor.SfPdfViewer

 

CDN Links:

 

https://cdn.syncfusion.com/blazor/30.1.38/styles/bootstrap5.css

https://cdn.syncfusion.com/blazor/30.1.38/syncfusion-blazor-sfpdfviewer.min.js



Marked as answer
Loader.
Up arrow icon