Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropdownBlock automatically closes up when clicking on element inside #130

Open
bnoemie opened this issue Apr 22, 2021 · 3 comments
Open

Comments

@bnoemie
Copy link

bnoemie commented Apr 22, 2021

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 bnoemie changed the title dropdownBlock automatically clloses up when clicking on DT::DTOuput functionnalities dropdownBlock automatically closes up when clicking on DT::DTOuput functionnalities Apr 22, 2021
@DivadNojnarg DivadNojnarg changed the title dropdownBlock automatically closes up when clicking on DT::DTOuput functionnalities dropdownBlock automatically closes up when clicking on element inside Apr 22, 2021
@DivadNojnarg
Copy link
Member

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) {}
)

@bnoemie
Copy link
Author

bnoemie commented Apr 27, 2021

Thanks a lot for your answer !

@ComeMaes
Copy link

ComeMaes commented Oct 10, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants