R Shiny dropdownButton在点击时立即关闭

时间:2018-05-09 01:04:43

标签: r shiny dropdown

我在服务器端创建 dropdownButton 时才发现此问题:

ui.R

library(shiny)
shinyUI(fluidPage(
   uiOutput("uiWidget")
))

server.R

library(shiny)

shinyServer(function(input, output) {
    output$uiWidget <- renderUI({
    dropdownButton(
    label = "Controls",
    icon = icon("sliders"),
    status = "primary",
    circle = FALSE,
    sliderInput(
       inputId = "n",
       label = "Number of observations",
       min = 10, max = 100, value = 30
    ),
    prettyToggle(
       inputId = "na",
       label_on = "NAs keeped",
       label_off = "NAs removed",
       icon_on = icon("check"),
       icon_off = icon("remove")
    ))
   })
})

对于上面的代码,当我单击内部的sliderInput时,弹出窗口将立即关闭。但是,当我在ui.R上创建 dropdownButton 时,它工作正常。 以下是源代码:

ui.R

library(shiny)

shinyUI(fluidPage(
  dropdownButton(
  label = "Controls",
  icon = icon("sliders"),
  status = "primary",
  circle = FALSE,
  sliderInput(
    inputId = "n",
    label = "Number of observations",
    min = 10, max = 100, value = 30
  ),
  prettyToggle(
    inputId = "na",
    label_on = "NAs keeped",
    label_off = "NAs removed",
    icon_on = icon("check"),
    icon_off = icon("remove")
  ))
))

对此有何解释?我还注意到,shinyWackts包中的下拉列表具有一致的行为。

1 个答案:

答案 0 :(得分:0)

我无法重现所描述的行为。 更改滑块或切换&#34; na&#34; -input时,下拉菜单保持打开状态。

也许更新你的闪亮包装并再次检查?我的闪亮版本是1.0.5和shinyWidgets 0.4.2