show_if
variation
#98
-
DescriptionI think the |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 3 replies
-
Can you provide a quick demo? like a simple |
Beta Was this translation helpful? Give feedback.
-
Okay I can reproduce this. In this example the hidden question won't show at all when you choose "other" on the first question:
---
format: html
echo: false
warning: false
---
```{r}
library(surveydown)
```
::: {#page1 .sd-page}
```{r}
sd_question(
type = 'mc',
id = 'penguins',
label = "Which is your favorite type of penguin?",
option = c(
'Adélie' = 'adelie',
'Chinstrap' = 'chinstrap',
'Gentoo' = 'gentoo',
'Other' = 'other'
)
)
sd_output(id = 'penguins_other', type = 'question')
sd_next()
```
:::
::: {#end .sd-page}
## This is the end of the demo survey showcasing the conditional display feature.
```{r}
sd_close()
```
:::
library(surveydown)
server <- function(input, output, session) {
sd_question(
type = "text",
id = "penguins_other",
label = "Please specify the other penguin type:"
)
sd_show_if(
input$penguins == "other" ~ "penguins_other"
)
sd_server()
}
shiny::shinyApp(ui = sd_ui(), server = server)
|
Beta Was this translation helpful? Give feedback.
-
Okay I just pushed a patch. Try reinstalling and see if this works: remotes::install_github("surveydown-dev/surveydown", force = TRUE) |
Beta Was this translation helpful? Give feedback.
-
Such a small little bug. Thanks for the quick notice. We tried to make sure everything was still working after making such big changes to the architecture. One more thing we noticed is the little red asterisk for required questions won't show on questions defined in the server. The required feature still works, but the question label is just missing the red asterisk. We'll have it patched soon. |
Beta Was this translation helpful? Give feedback.
-
Ah, good catch. @pingfan-hu can you take a look at this? By moving from a Quarto shiny document to now just a regular Quarto doc + a shiny app, we lost some of the nice formatting that Quarto handled for us. Pingfan has been working on the UI to try and make things looks similar to how they rendered before. |
Beta Was this translation helpful? Give feedback.
-
I didn't intentionally modify the buttons. The old layout has equal width because quarto renders it this way. Now since it becomes a Shiny app, it's rendered differently. I'll see if I can do something in the css or insert some JS codes. |
Beta Was this translation helpful? Give feedback.
-
Hi @willking98 , I've solved your problem. You can see the screenshot here: This is done by defining the For your convenience, I've modified all your Another parameter is called Please update our package and try it: remotes::install_github("surveydown-dev/surveydown", force = TRUE) Now we have a bug that if you define width as 80%, the question container will take 80% of the page width, but then the button width will be 80% of the container, making the button width being 64% of the page. I will fix it later. |
Beta Was this translation helpful? Give feedback.
-
@willking98 As a follow-up, the |
Beta Was this translation helpful? Give feedback.
-
Brilliant, that now works really well. Thanks @pingfan-hu! |
Beta Was this translation helpful? Give feedback.
Hi @willking98 , I've solved your problem. You can see the screenshot here:
This is done by defining the
direction
parameter as"vertical"
inmc_buttons
. This parameter is available for bothmc_buttons
andmc_multiple_buttons
, default to"horizontal"
.For your convenience, I've modified all your
mc_buttons
questions to have vertical alignment:demo-choice-based-conjoint-modified.zip
Another parameter is called
"width"
. You can define it as"400px"
or"80%"
so that you can control the width of the question container, which then affects the box length. The texts will automatically wrap if they are too long, like this:Please update our package and try it: