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

rintrojs Cannot find selectizeInput element after choices are updated. #62

Open
davidaarmstrong opened this issue Apr 23, 2024 · 0 comments

Comments

@davidaarmstrong
Copy link

I have an app that generates choices for selectizeInput() based on the value of another selector. Specifically, it finds the unique values of the selected variable and then makes those choices. I initialize the selector with selectizeInput() in the UI and then use observe({}) to identify changes in the inputs and then call updateSelectizeInput() to change the choices. This all works fine.

The problem I am running in to is when I use rintrojs, the selector of choices is identified the first time through the app, but when the choices update, if I try to go back to those again, the element cannot be found. Here's a few screenshots that identify the problem. First, here's the screenshot of the first step of the tutoria:

image

Next, I can choose two values from the compare groups selector.

image

Next, it sends me back to choose a different value for Group 1, I choose "y".

image

Finally, when the tutorial tries to go back to the comparison groups, it just pushes the tooltip to the top left corner.

image

But, there hasn't been any problem updating the selector, you can see it now has the values D, E and F.

image

Do you have any idea why I cannot return to the compare groups selector once the choices have been updated. Here's the toy example.

library(shiny)
library(rintrojs)
# Define UI for application that draws a histogram
ui <- fluidPage(
  
  # Application title
  titlePanel("IntroJS Problem"),
  
  # Sidebar with a slider input for number of bins 
  sidebarLayout(
    sidebarPanel(
      actionButton("browser", "browser"),
      introjsUI(),
      actionButton("btn","Interactive Tutorial"),
      selectizeInput("grp1", 
                     "Grouping Variable", 
                     choices = c("x", "y"), 
                     selected="x"),
      selectizeInput("compgroup", "Compare Groups (Choose 2)", choices="", multiple=TRUE, options=list(maxItems=2))
    ),
    
    
    # Show a plot of the generated distribution
    mainPanel(
    )
  )
)

# Define server logic required to draw a histogram
server <- function(input, output, session) {
  library(rintrojs)
  observeEvent(input$browser,{
    browser()
  })

  observe({
    g1 <- input$grp1
    if(g1 == "x"){
      chc <- c("A", "B", "C")
    }
    if(g1 == "y"){
      chc <- c("D", "E", "F")
    }
    updateSelectizeInput(session, "compgroup", choices = chc)
  })
  
  
  steps <- reactive({ 
    data.frame( 
      element = c("#grp1 + .selectize-control", 
                  "#compgroup + .selectize-control", 
                  "#grp1 + .selectize-control", 
                  "#compgroup + .selectize-control"),
      intro = c("Choose x for Group 1",
                "Choose two values for Comparing Groups", 
                "Choose y for Group 1", 
                "Choose two values for Comparing Groups"),
      position = "right")
  })
  observeEvent(input$btn, introjs(session, options = list(steps=steps())))
  
}
# Run the application 
shinyApp(ui = ui, server = server)
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

1 participant