vaadin-component-factory / vcf-pdf-viewer-flow

Vaadin Addon for providing pdf viewing functionality
Apache License 2.0
8 stars 6 forks source link

Download button is added multiple times in cases where onAttach is called multiple times #45

Closed drewharvey closed 6 months ago

drewharvey commented 6 months ago

Description

The download button will be duplicated n-number of times if the onAttach is called multiple times. One common case is if the pdf viewer component is in a dialog and this dialog gets opened multiple times.

pdf-multiple-download-btns

Version

Vaadin 23 (did not test 24) PdfViewer 2.7.2 (latest for Vaadin 23)

Reproduce Steps

  1. Add code snipet below to a view
  2. Click button to display pdf viewer in dialog
  3. Close dialog
  4. Click button to open dialog again - notice the download button has been added twice

Reproduce Example

var pdfViewer = new PdfViewer();
pdfViewer.setAddDownloadButton(true);
pdfViewer.setWidthFull();

var dialog = new Dialog();
dialog.setWidth("800px");
dialog.add(pdfViewer);

add(new Button("Show Dialog", e -> dialog.open()));