JohnCoene / waiter

🕰️ Loading screens for Shiny
https://waiter.john-coene.com/
Other
495 stars 25 forks source link

HTML elements with shiny input bindings don't work in waiter screens? #145

Open TransGirlCodes opened 10 months ago

TransGirlCodes commented 10 months ago

Hi, I thought of creating a custom widget for putting into loading screens for unavoidable loading times: provide a very lightweight game like 'snake' to give the user something to fidget with.

So that's what I did: I built a class for a simple snake engine in vanilla js, created the Shiny Input Binding for it (thought it would be cool to allow the possibility of passing scores and such to the R side in the future), and when I put it in the main page of the UI it works. But not when it's put in the HTML for the waiter screen (html argument for show_waiter.

I then experimented and stuck an actionButton in the waiter's html and hooked it up to a bindEvent to print to REPL on click, and that button also does not work. So do elements with input bindings not work in waiter screens? Is there a way around this?

Here's a link to my dummy rhino app with the widget. The app shows the working game element in the main page and has a button to trigger the waiter screen, which contains the non-working game element. https://github.com/TransGirlCodes/ShinySnakeTest

JohnCoene commented 7 months ago

Hi @TransGirlCodes sincere apologies for the late response. I've been tied with work for quite some time and your issue totally escaped me, I'm really sorry!

I think I may eventually be able to fix this with.

  window.Shiny.renderDependenciesAsync(opts.content.deps).then(() => {
    window.Shiny.renderContentAsync($(`#${opts.id}`), opts.content.html).then(
      () => {
        // ...
      },
    );
  });

Coupled with

process_deps <- function(...) {
  utils::getFromNamespace("processDeps", "shiny")(...)
}