rstudio / shinydashboard

Shiny Dashboarding framework

Home Page:https://rstudio.github.io/shinydashboard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

updateTabsetPanel does not work with tabBox

tomicapretto opened this issue · comments

I want to have a button inside a tabPanel within a tabBox that when clicked switches to another tabPanel within the same tabBox.

None of the approaches I tried worked. Also, I couldn't find much documentation on how this is expected to work.

I'm using shiny 1.5.0 and shinydashboard 0.7.1

Concisely, is this the correct approach? Is it possible to do what I am trying to do?
Thank you!

  library(shiny)
  library(shinydashboard)
  
  ui <- dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
      fluidRow(
        tabBox(
          id = "tabs",
          height = "auto",
          width = 12,
          title = "",
          tabPanel(
            title = "Title1",
            value = "one",
            actionButton("move", "Move!")
          ),
  
          tabPanel(
            title = "Title2",
            value = "two",
            actionButton("moveback", "Move back!")
          )
        )
      )
    )
  )
  
  server <- function(input, output, session) {
    observeEvent(input$move, {
      print("move!")
      updateTabsetPanel(session, "tabs", "one")
    })
    observeEvent(input$moveback, {
      print("moveback!")
      updateTabsetPanel(session, "tabs", "two")
    })
    observeEvent(input$tabs, print(input$tabs))
  }
  
  shinyApp(ui, server)