dreamRs / capture

Take screenshots in Shiny apps
https://dreamrs.github.io/capture
GNU General Public License v3.0
32 stars 4 forks source link

Capture fails 'body' capture in conjunction with bslib package #4

Open Blocktt opened 3 years ago

Blocktt commented 3 years ago

I added the bslib package (custom CSS themes) to my R shiny app but have run into an issue with the 'Capture' download button. Without the bslib package, the Capture package works perfectly fine without any issues. Strangely, I don't have a problem until after I upload a csv file for manipulation (app takes a file and calculates stats on it). Said another way, Capture will screenshot the entire web page when there is no file is uploaded but will not work afterwards. Perhaps it's a CSS targeting issue? I'm running the app on Google Chrome. Here is the breakdown:

  1. Capture works fine to download an image of the full screen prior to the csv file being loaded. ,capture::capture(selector = "body" , filename = "all-page.png" , icon("camera-retro") , "Take screenshot of entire page" , class = "btn-primary")

  2. After the file is uploaded, the capture function stops working. Below is the inspection error I receive from Google Chrome. `capture.js:65 Capture: oops, something went wrong! Event bubbles: false cancelBubble: false cancelable: false composed: false currentTarget: null defaultPrevented: false eventPhase: 0 isTrusted: true path: [img] returnValue: true srcElement: null target: null timeStamp: 33897.700000047684 type: "error"

Am I missing something here? I can't see why capture would work before the csv file is loaded and not afterward. The app I'm running this on is quite complex, therefore, a reprex would not be useful.

pvictor commented 3 years ago

Not sure how I can help you without being able to reproduce the error. Without bslib it works fine even after uploaded a file ? You use Bootstrap 4 with bslib ?

Otherwise, maybe you will have better luck with shinyscreenshot ?

Blocktt commented 3 years ago

I understand... Perhaps it's best to just not use bslib because I'd prefer to keep the Capture functionality. Without bslib, the Capture function works completely fine and has no issues after a file is uploaded. I believe bslib uses Bootstrap 4 or 5 but honestly, I'm not sure the difference or the effects those differences would have.

Either way, somehow to the bslib package interferes with the Capture function but there isn't a clear error that is produced so it's likely on the HTML side of things. Will probably need to just avoid the combination of packages.

Thanks, Ben