首页 > 解决方案 > 在可拖动的绝对窗格中向下滚动 selectInput

问题描述

当我运行下面的应用程序时,我无法使用右侧的滚动条向下滚动下拉菜单,因为它会导致下拉菜单立即消失。我只能使用鼠标的滚轮向下滚动。如果我不在可拖动面板中,则问题不存在。

我需要在一个可拖动的面板中,我不希望人们使用我的应用程序对这个向下滚动菜单感到沮丧。

有人知道如何解决这个问题吗?

非常感谢!

我正在使用包 Shiny 的 1.0.5 版本。该问题出现在查看器面板(RStudio 版本 1.1.442、R 版本 3.4.4)和应用程序在 Google Chrome 外部运行时(版本 67.0.3396.99)。

这是应用程序的代码。

library(shiny)

ui <- absolutePanel( id = "controls", class = "panel panel-default", fixed = TRUE,
           draggable = TRUE, top = 60, left = "auto", right = 20, bottom = "auto",
           width = 500, height = "auto",

           uiOutput( 'color' )          
)

server <-   function( input, output, session ) {
output$color <- renderUI( selectInput(  inputId = "color", label = h4( "Variable" ), 
                                        selectize = TRUE, choices = LETTERS, 
                                        # selectize = TRUE, choices = varLst[[ input$varType ]][[ input$measType ]],
                                        selected = 'A') )
}

shinyApp(ui, server)

标签: rshiny

解决方案


一个解决方案包括设置draggable=FALSE和包装包提供的absolutePanel内部 a ,并带有选项.jqui_draggableshinyjquicancel = ".selectize-control"

library(shiny)
library(shinyjqui)
ui <- jqui_draggable(
  absolutePanel( id = "controls", class = "panel panel-default", fixed = FALSE,
                 draggable = FALSE, top = 60, left = "auto", right = 20, 
                 bottom = "auto", width = 500, height = "auto",
                 uiOutput( 'color' )
  ),
  options = list(cancel = ".selectize-control"))

推荐阅读