简体   繁体   中英

R shinyhelper fails with htmlOutput

R shinyhelper's observe_helpers function does not see helpers passed through an output function like htmlOutput , which is unfortunate because it is an otherwise useful little package. The following is a MWE.

UI

library(shiny)
library(shinyhelper)

ui = fluidPage(
  sidebarLayout(
    sidebarPanel(
      selectInput("var", 
                  label = "var",
                  choices = c("A", "B", "C", "D")) %>% 
        helper(icon="question",                                          
               type="markdown",
               content="herp")),        
    mainPanel(
      htmlOutput("selected"))
))

Server

server = function(input, output,session) {
  observeEvent(input$var, {
    if(input$var=="B"){
       output$selected <- renderUI({ 
                            fluidRow(
                              column(4,textInput(inputId="derp",
                                                 label="derp") %>% 
                                         helper(icon="question", 
                                                type="markdown",                                                                 
                                                content="flerp")),
                              column(8))})
}})

  observeEvent(input$derp, {print(input$derp)})

  observe_helpers()  

}

runApp(list(ui = ui, server = server))

I am aware that helper works when connected by pipe to htmlOutput , but this is not helpful when we want to render a UI in the server that contains multiple widgets with their own helpers.

Any suggestions for how to fix this issue would be appreciated.

现在,您可以更新到Shinyhelper v0.3.1,它应该可以解决此问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM