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

shinyWidgets::downloadBttn() cant be selected with tab and highlighted #724

Open
pgomba opened this issue Jan 17, 2025 · 1 comment
Open

Comments

@pgomba
Copy link

pgomba commented Jan 17, 2025

Hi,

Currently, it is possible to navigate between elements of a Shiny app using the Tab key, with the elements getting highlighted. For instance, this works in shinyWidgets::downloadBttn() by setting no_outline = FALSE.

However, it seems that switchInput() does not exhibit the same behavior, and it even appears to be impossible to select the switch using the Tab key.

Could you please let me know if I'm overlooking something, or if there are plans to add this feature in the future?

Thanks!
Example ShinyApp: https://pagoba.shinyapps.io/LiClcalc/
Code caption:

Image

@pgomba
Copy link
Author

pgomba commented Jan 17, 2025

Note that I've been able to find a workaround by adding this code to the app:

tags$script(HTML(" $(document).ready(function() { // Listen for keydown event to toggle switch $('#unit_switch_container').on('keydown', function(event) { if (event.key === 'Enter' || event.key === ' ') { $('#unit_select').prop('checked', !$('#unit_select').prop('checked')).trigger('change'); } }); }); "))

and wrap the switch button like this:

tags$div( tabindex = "0", # Make the switch input focusable via tab id = "unit_switch_container", switchInput( inputId = "unit_select", label = "Switch units", onLabel = "g/L", offLabel = "g/100 ml", value = TRUE, size = "mini", handleWidth = 300, onStatus = "danger", offStatus = "danger" ) )

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