shinydashboardPlus
shinydashboardPlus copied to clipboard
dropdownBlock automatically closes up when clicking on element inside
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.
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) {}
)
Thanks a lot for your answer !
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?