dreamRs / shinyWidgets

shinyWidgets : Extend widgets available in shiny
https://dreamrs.github.io/shinyWidgets/
GNU General Public License v3.0
818 stars 152 forks source link

`sliderTextInput` compatibility problem on Quarto doc in the argument `choices`. #689

Open pingfan-hu opened 3 months ago

pingfan-hu commented 3 months ago

ShinyApp Works Fine

The sliderTextInput function works out fine on ShinyApp, like this:

sliderTextInput(
   inputId = "Id095",
   label = "Choose a letter:", 
   choices = c("a", "b", "c", "d", "e")
)

Quarto Doc Not Compatible

However, it has compatibility problem on Quarto doc. The choices argument should be used to define the character vector to select a value from, but Quarto doc doesn't recognizes it and keeps showing a default range from 10 to 100, not matter what range I set, or if I use character vector instead.

Below is my example (you can paste these codes into a blank quarto doc and reproduce it):

---
title: "Slider Text Input Example"
format: html
server: shiny
execute: 
  warning: false
---

```{r}
library(shiny)
library(shinyWidgets)
sliderTextInput("Id095", "Choose a letter:",
                choices = c("a", "b", "c", "d", "e"))
textOutput("selected_letter")
#| context: server
output$selected_letter <- renderText({
  paste("You have selected the letter:", input$Id095)
})


## Screenshots
Here is a screenshot of a successful implementation on the ShinyApp:
![ShinyApp Works Fine](https://github.com/dreamRs/shinyWidgets/assets/84371500/0f74eaef-9a3a-45d1-a2b2-6c6b8decd499)

Here is another screenshot of Quarto Doc. You can see the range is set as from 10 to 100, which is probably a default value. I tried to set a custom range with a character vector but it was ignored:
![Quarto Doc Has Error on the Range](https://github.com/dreamRs/shinyWidgets/assets/84371500/660ef471-72cb-4972-aeea-fd2a1bc8664f)

If anyone encountered with the same issue, or if you have a solution, please comment below. I appreciate your help!
etschste commented 1 month ago

I encountered the same problem.

pingfan-hu commented 1 month ago

Yeah this is a relatively rare problem and will only occur when you want to use shiny as server on your qmd file. In usual cases people use the ShinyApp and it works out fine. Hopefully the shinyWidgets team could provide some guidance to us.