I have quite an interesting problem. I have a number of checkboxes for input in Shiny (naturally), everything works fine, if I click a checkbox and wait like half a second and click the next (the screen dims to grey and then the checkbox is checked and the I can continue). However, if I check a checkbox without waiting (just before the screen goes grey) shiny ends up in an infinite loop.
I cannot give the full code, but the just of it is provided.
obs_ev <- "c(input[['cbox_gr1']], input[['cbox_gr2']]")
observeEvent(eval(parse(text = obs_ev)), {
dat <- eval(parse(text = obs_ev))
v1 <- input$v2
v2 <- v2_short_list[v2_list == input$v2]
# Only need the first one since v1 and v2 are the same for all inputs
dat_temp <- dat[1]
# Dataframe to update
v1_updt <- gsub("_-_", "\\2", dat_temp)
v2_updt <- gsub("_-_", "\\3", dat_temp)
focused.df <- paste0(gsub(" ", "_", v1), "_", v2)
working.df.name <- paste0(v1_updt, "_", v2_updt)
if (focused.df == working.df.name) {
print(dat)
# V3 to update
v3_updt <- gsub("_-_", "\\1", dat_temp)
reactive.df.name <- paste0(v1_updt, "_", v2_updt, "_react")
# Rows to update
rows_updt <- as.numeric(gsub("_-_", "\\4", dat))
# Update data based on checkbox input
eval(parse(text = paste0("temp_updt <- ", working.df.name)))
tbc <- temp_updt[[v3_updt]][!temp_updt$key %in% rows_updt]
tbc[tbc == 2] <- 1
temp_updt[[v3_updt]][!temp_updt$key %in% rows_updt] <- tbc
temp_updt[[v3_updt]][rows_updt] <- 2
# Overwrite the dataframe (not the reactive one, but instead the one that the reactive dataframe is linked to)
eval(parse(text = paste0(working.df.name, " <<- temp_updt")))
}
})
Again, the code is working just fine, except for the delay in the click - the fact that Shiny 'fades' in and out when I click on a checkbox, even more, the fade doesn't bother me that much (I would like it gone though) the fact that if I click before the fade, the whole thing ends up in a loop