JohnCoene / cicerone

🏛️ Give tours of your Shiny apps
https://cicerone.john-coene.com
Other
187 stars 7 forks source link

Example with navbar not working #9

Closed etiennebacher closed 4 years ago

etiennebacher commented 4 years ago

I just discovered this nice package and tried to reproduce the examples provided here.

I think there is a problem with this one since the second guide (for the second tab) does not run when the first guide is over. I guess one problem is that you used updateTabsetPanel instead of updateNavbarPage but even with this, it doesn't work. I put the code here only for convenience:

library(shiny)
library(cicerone)

home_guide <- Cicerone$
  new(id = "homeGuide")$
  step(
    "home_primary",
    "Hello",
    "Hello from tab 1"
  )$
  step(
    "home_secondary",
    "Text",
    "This is an input"
  )

tab_guide <- Cicerone$
  new()$
  step(
    "tab_primary",
    "Hello",
    "Hello from tab 2"
  )$
  step(
    "tab_secondary",
    "Text",
    "This is an input"
  )

ui <- navbarPage(
  "cicerone",
  header = list(use_cicerone()),
  id = "nav",
  tabPanel(
    "home",
    h1("First tab", id = "home_primary"),
    textInput("home_secondary", "Text")
  ),
  tabPanel(
    "tab",
    h1("First tab", id = "tab_primary"),
    textInput("tab_secondary", "Text")
  )
)

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

  home_guide$init()$start()

  observeEvent(input$homeGuide_has_next_step, {
    next_step <- input$homeGuide_has_next_step
    if(is.null(next_step)) next_step <- TRUE

    if(!next_step){
      updateTabsetPanel(session, "nav", "tab")
      tab_guide$init()$start()
    }
  })

}

shinyApp(ui, server)

Besides, I'm wondering why the workflow for navbarpage and fluidpage are not identical:

Why not making the same system for navbarPage by using the id of the navbar instead of the id of tabsetPanel?

JohnCoene commented 4 years ago

Indeed, thank you for pointing this out. I had added tab-related arguments recently and had overlooked this. I updated the docs