shinydashboardPlus icon indicating copy to clipboard operation
shinydashboardPlus copied to clipboard

dropdownBlock automatically closes up when clicking on element inside

Open bnoemie opened this issue 3 years ago • 3 comments

Hi, I've noticed an unwanted behavior with the latest version 2.0.0. If I use a shinydashboardPlus::dropdownBlock to show a datatable object with DT::DTOutput then any click on the datatable functionnalities (pages numbers, columns' order button, etc.) will close up the dropdownBlock.

I've tried to made a reproducible example of my experience :

if (interactive()) {
  library(shiny)
  library(shinyWidgets)
  library(shinydashboard)
  library(shinydashboardPlus)
  
  shinyApp(
    ui = dashboardPage(
      header = dashboardHeader(
        leftUi = tagList(
          shinydashboardPlus::dropdownBlock(
            id = "mydropdown",
            title = "Iris",
            badgeStatus = "warning",
            icon = shiny::icon("info"),
            DT::DTOutput("iris_dt")
          )
        )
      ),
      sidebar = dashboardSidebar(),
      body = dashboardBody(
        setShadow(class = "dropdown-menu")
      ),
      title = "DashboardPage"
    ),
    server = function(input, output) {
      output$iris_dt <- DT::renderDT({
        DT::datatable(iris)
      })
    }
  )
}

Could you tell me please if you noticed the same behavior on your side ? Don't hesitate if you need any addtionnal info from me.

bnoemie avatar Apr 22 '21 14:04 bnoemie

Hi,

Thanks for using the package. In theory, this is not advised to display a table inside a dropdownBlock, which was originally designed to contain inputs.

However, you're right, there is an issue. Below, the selectInput should not close the dropdown menu:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

shinyApp(
    ui = dashboardPage(
        header = dashboardHeader(
            leftUi = tagList(
                shinydashboardPlus::dropdownBlock(
                    id = "mydropdown",
                    title = "Iris",
                    badgeStatus = "warning",
                    icon = shiny::icon("info"),
                    selectInput("sksk", "sksksk", colnames(mtcars))
                )
            )
        ),
        sidebar = dashboardSidebar(),
        body = dashboardBody(),
        title = "DashboardPage"
    ),
    server = function(input, output) {}
)

DivadNojnarg avatar Apr 22 '21 15:04 DivadNojnarg

Thanks a lot for your answer !

bnoemie avatar Apr 27 '21 13:04 bnoemie

Hi, I am experiencing the same behaviour with radioButtons. The difference with the code in the above example is that in ui.R I am using a dropdownMenuOutput, like so:

leftUi = tagList(
    dropdownMenuOutput("mySelectionMenu")
)

Then in server.R, I puy the dropdownBlock in a renderMenu:

output$mySelectionMenu <- renderMenu({
  dropdownBlock(id = "mySelectionDropdownMenu",
                title = "select",
                badgeStatus = NULL,
                div(style = "margin-top: 10px;",
                    radioButtons(inputId = "mySelection", 
                                 label = NULL, 
                                 choices = x, 
                                 selected = x))))
})

Whenever I select an option in the radio buttons input, the dropdownBlock closes. If I put it directly in the leftUI tagList, it works as expected. The reason I need to put this in a dropdownMenuOutput (or any output for that matter) is that I would like the title of the dropDownBlock to be translated based on some configuration input. Any ideas on how to work around this?

ComeMaes avatar Oct 10 '22 10:10 ComeMaes