Skip to content

iframe does not set src #50

Description

@rbozan

Hi, thanks for the package.

I'm on version 2.7.4 of this package, upgraded from 2.7.2.

I have a bug where sporadically the PDF viewer will not work within a React application. It seems that whenever this happens, the "src" of the iframe is set to about:blank (or undefined).

I'm not quite sure where the bug is as I'm not that familiar with custom web components, but under the disconnectedCallback it seems that it's setting the url to about:blank:

this.iframe.src = 'about:blank'

However it seems that connectedCallback could be called multiple times, so I am guessing that under that function connectedCallback something is incorrect.
Perhaps with:

viewerOptions?.set('defaultUrl', this.getFullPath(this.getAttribute('src') || DEFAULTS.src))

When the bug occurs I am seeing the following in the Element inspector:

<pdfjs-viewer-element src="(URL)" viewer-extra-styles="#toolbarViewerRight { display: none }" viewer-path="(URL)" locale="nl" data-sentry-element="pdfjs-viewer-element" data-sentry-component="PdfViewer" data-sentry-source-file="pdf-viewer.tsx" style="height: calc(100vh - var(--app-shell-header-height, 0px) - var(--app-shell-footer-height, 0px));"><template shadowrootmode="open">
      <style>:host{width:100%;display:block;overflow:hidden}:host iframe{height:100%}</style>
      <iframe frameborder="0" width="100%" loading="lazy" title="PDF viewer window"></iframe>
    </template></pdfjs-viewer-element>
Image

Note that there's no srcdoc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions