Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 'hide_on_render=TRUE' on a plot, does not work #94

Closed
sigmapi opened this issue May 29, 2021 · 5 comments
Closed

Using 'hide_on_render=TRUE' on a plot, does not work #94

sigmapi opened this issue May 29, 2021 · 5 comments

Comments

@sigmapi
Copy link

sigmapi commented May 29, 2021

Hi,
using hide_on_render=TRUE on a ggplot fails to hide the waiter after the value(or error) Shiny events.

I noticed some errors in the javascript code (waiter.js):

// remove when output receives value
$(document).on('shiny:value', function(event) {
  if(waiter_to_hide.indexOf(event.name) > 0){
    hide_waiter(event.name);
  }
});

Javascript arrays are 0 based. So the comparison above will naturally become false, even if the correct element is in the array with index 0.
This is the correct way:

// remove when output receives value
$(document).on('shiny:value', function(event) {
  if(waiter_to_hide.indexOf(event.name) > -1){
    hide_waiter(event.name);
  }
});

This should be changed for operations in all three arrays: waiter_to_hide, waiter_to_hide_on_error, waiter_to_hide_on_silent_error. And perhaps on other javascript files too?

@JohnCoene
Copy link
Owner

Thanks, well spotted. I just changed it to use includes instead. It should work with the dev version.

@sigmapi
Copy link
Author

sigmapi commented May 29, 2021

Thanks for the quick response.
Be aware that includes is not fully supported method, I suggest sticking to indexOf.
https://caniuse.com/?search=Array.prototype.includes

On the same topic, items are added to these three arrays but they are never removed. Shouldn't they?

Should I call waiter_show every time a plot is regenerated on the server?
Or once per session?

@sigmapi
Copy link
Author

sigmapi commented May 29, 2021

One more thing: how do we specify from server side the hide_on_error, waiter_to_hide_on_error?
Currently when I use waiter_show, only the to_hide flag is set.

Perhaps there is no need for three separate arrays. Is there a scenario where a user would want the spinner (in this auto-hide case) to continue in case of an error?

@sigmapi
Copy link
Author

sigmapi commented May 29, 2021

And another thing (sorry, I just write what I notice, when I use the waiter_show on a plot render):
In hide_recalculate a style is added to the document head and it never gets removed.
After recalculating a plot several times in a session, the head is full of these repeating styles.

@JohnCoene
Copy link
Owner

Thanks for this!

I'll be honest I have not taken care of the waiter_show function too much because I want to push for the use of the reference class. I initially had both the functional and class APIs thinking it would make it easier but it does not, on the contrary.

You can specify the arguments you ask about here:

initialize = function(id = NULL, html = NULL, color = NULL, logo = NULL,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants