RinteRface / shinydashboardPlus

extensions for shinydashboard
https://shinydashboardplus.rinterface.com
Other
454 stars 77 forks source link

navlistPanel in right controlbar not behaving as expected #127

Closed markuszinser closed 3 years ago

markuszinser commented 3 years ago

Hi,

I experienced a weird behavior with the latest version 2.0.0. If I create a right sidebar and add a navlistPanel, the input value of the navlistPanel does not correspond to the value of the tabPanel (see: https://shiny.rstudio.com/reference/shiny/0.14/tabsetPanel.html). Instead it returns the selected row number. It seems to work for a tabsetPanel. and it worked in the previous version. A shiny-only example also seems to work.

I created a small example app which reproduces the behavior:

library(shiny)

ui <- shinydashboardPlus::dashboardPage(
    header = shinydashboardPlus::dashboardHeader(),
    sidebar = shinydashboardPlus::dashboardSidebar(),
    body = shinydashboard::dashboardBody(),
    controlbar = shinydashboardPlus::dashboardControlbar(
        skin = "dark",
        shinydashboardPlus::controlbarMenu(
            id = "menu",
            shinydashboardPlus::controlbarItem(
                "Tab 1",
                "Welcome to tab 1",
                shiny::tabsetPanel(id = "my_tabset")
            ),
            shinydashboardPlus::controlbarItem(
                "Tab 2",
                "Welcome to tab 2",
                shiny::navlistPanel(id = "my_navlist")
            )
        )
    ),
    title = "Right Sidebar"
)

server <- shinyServer(function(input, output) {

    appendTab(
        inputId = "my_tabset",
        tab = shiny::tabPanel(
            title = "tab1",
            value = "tab1"
        )
    )

    appendTab(
        inputId = "my_tabset",
        tab = shiny::tabPanel(
            title = "tab2",
            value = "tab2"
        )
    )

    appendTab(
        inputId = "my_navlist",
        tab = shiny::tabPanel(
            title = "tab1",
            value = "tab1"
        )
    )

    appendTab(
        inputId = "my_navlist",
        tab = shiny::tabPanel(
            title = "tab2",
            value = "tab2"
        )
    )

    observe({
        print("Selected Tabset: ")
        print(input$my_tabset)
        print("Selected Navlist: ")
        print(input$my_navlist)
    })
})

shinyApp(ui = ui, server = server)

If you switch in the second tab between the items in the list, a number is printed instead of the value of the tabPanel.

DivadNojnarg commented 3 years ago

Hi,

Thanks. This one was subtile! There was a conflict with the navPills() JS binding, which was overwriting the shiny::navlistPanel binding...

As a side note, I would not advise to insert a navlist panel inside a sidebar. There is not enough space for proper rendering.