juba / shinyglide

Glide.js component for Shiny apps
https://juba.github.io/shinyglide/
91 stars 8 forks source link

Unexpected behavior when using the tab key to jump between fields #25

Closed Chaskelr closed 3 years ago

Chaskelr commented 3 years ago

Hi,

Thank you for the great package, I really enjoy working with it! Recently I encountered one issue though: Whenever I use the tab key to jump between input fields, the smooth transition from one screen to the next does not seem to work properly anymore. There are two problems:

I tried using “keyboard = FALSE” in the development version, but it does indeed only disable the arrow keys. Hence my question: Would it be possible to include a functionality that also disables the tab key, so that I can prevent this behavior? Please see my (hopefully) reproducible example below.

library(shiny)
library(shinyglide)

ui <- fixedPage(titlePanel("MWE: Tab Key"),

                glide(
                  keyboard = FALSE,
                  screen(
                    p("It is not possible to meet the next_condition (n < 10 in this case)."),
                    p("Going to the next screen should therefore be impossible."),
                    p("However, see what happens when you click on the input field and then hit the tab key."),
                    numericInput("n", "First field", value = 10, min = 10),
                    next_condition = "n < 10"
                  ),
                  screen(
                    p("You jumped + the page is not displayed correctly."),
                    plotOutput("plot"),
                    numericInput("x", "Second field", value = 1)
                  )
                )
)

server <- function(input, output, session) {
  output$plot <- renderPlot({
    hist(
      rnorm(input$n),
      main = paste("n =", input$n),
      xlab = ""
    )
  })
}

shinyApp(ui, server)
juba commented 3 years ago

Thanks for taking the time to report this issue I was not aware of with a reproducible example.

I think this should now be fixed in the development version, tab navigation should be limited to the current visible slide. Don't hesitate to let me know if it is working or not for you.

Chaskelr commented 3 years ago

Thank you so much! It works perfectly now.