rstudio / shiny

Easy interactive web applications with R
https://shiny.posit.co/
Other
5.35k stars 1.87k forks source link

no response when switching between menuSubItems after first clicked actionButton #1558

Open earthcli opened 7 years ago

earthcli commented 7 years ago

By using shiny and shinydashboard package,I have create a group of menuItems and menuSubItems as well as the coresponding tabItems, and there is a conditionalPanel with different input parameters for each menuSubItems, and an actionButton for different analysing and ploting task,now it works before the actionButton is clicked, that is, the conditionalPanel changed when switching between menuSubItems,and it also works well for the first time actionButton is clicked, that is it show a plot html as expected, but after the first clicked of actionButton, the conditionalPanel no longer changed as before when switching between menuSubItems, it seems that the menuSubItems can not update when clicked by mouse in the ui, How can I fix it?

the programs is so long that, I can only paste a piece of them as follows: the myshinyOutput is a selfdefined function for creating a html with input parameters.

server=function(input,output,session,dir="D:/ShinyServer"){
  observeEvent(input$sidebarmenu,{
    js$collapse("parbox")
    if(input$sidebarmenu=="a") {
      selmets=c("a"="a","b"="b")
      selstatistic=c("stat"="mean","statb"="anomaly")
      updateSelectInput(session,inputId="selmets",choices=selmets,selected=c("t","r","s"))
      updateSelectInput(session,inputId="selstatistic",label="sel:",choices=selstatistic,selected="mean")
      updateDateRangeInput(session,inputId="dateRange",start=inputdateRange$start,end=inputdateRange$end)
      updateSelectInput(session,inputId="selstationoption",selected="all")
      updateSelectInput(session,inputId="saveres",selected="plot")
      updateTextInput(session,inputId="compyear",value="")   
    }else if(input$sidebarmenu=="b") {
      selmets=c("sunshine","fog","haze","hail","snow","snowdepth")
      updateSelectInput(session,inputId="selmets",choices=selmets,selected=c("sunshine"))
      updateDateRangeInput(session,inputId="dateRange",start=inputdateRange$start,end=inputdateRange$end)
      updateSelectInput(session,inputId="saveres",selected="plot")
    }     
  })

  htmlvalues=reactive({
    if(input$runButton == 0)
    {
      return()
    }
   #isolate({
      input$runButton
      renderUI({isolate(myshinyOutput(input,rootdir=dir,htmlwidth=2000)$html)})
   #})
  })

  downloadlisthtml=reactive({
    if(input$runButton == 0)
    {
      return()
    }
   #isolate({
      input$runButton
      renderUI({isolate(gendownloadlisthtml())})
   #})
  })  

  observeEvent(input$runButton,
               {
                 js$collapse("parbox")
                 if(input$sidebarmenu=='grd'){

                 }else{
                   output[[paste(shinymodulesub(input$sidebarmenu),"_html",sep="")]]=htmlvalues()
                   output[[paste(shinymodulesub(input$sidebarmenu),"download_html",sep="")]]=downloadlisthtml()
                 }    
               })
}

# > sessionInfo()
# R version 3.3.2 (2016-10-31)
# Platform: i386-w64-mingw32/i386 (32-bit)
# Running under: Windows 7 (build 7600)
# 
# 
# other attached packages:
#   [1] shinydashboard_0.5.3
# [2] shiny_1.0.0         
# 
# loaded via a namespace (and not attached):
#   [1] R6_2.1.1        htmltools_0.3.5
# [3] tools_3.3.2     Rcpp_0.12.9    
# [5] digest_0.6.8    xtable_1.7-4   
# [7] httpuv_1.3.3    mime_0.3
alandipert commented 5 years ago

Hello, thank you for the report, and sorry to take so long to respond to you.

If this is still a problem you experience, a reproducible example would be exceedingly helpful.