Plotly does not show error message when inputs are invalid for Quarto dashboards in R
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the minimal .qmd reproduction in the issue and compare its Quarto dashboard behavior with the regular .R case described. Trace the interaction between plotly::renderPlotly() and shiny::validate(); done means the specified validation message appears for an out-of-range input instead of the previous plot.
Written by the indexing model from the issue text.
Description
I have:
- searched the issue tracker for similar issues
- installed the latest version of Quarto CLI
- formatted my issue following the Bug Reports guide
Bug description
Hi Quarto team, I believe I encountered a bug when plotly is used with shiny::validate() for Quarto dashboards in R.
I could not get plotly::renderPlotly() to work well with shiny::validate() when invalid values are inputted. Instead of showing the error message specified by validate() when there's an invalid input, renderPlotly() will display the previous plot. As far as I know, this bug only occurs for Quarto dashboards (.qmd) and does not appear in regular R scripts (.R). I have included an MRE below.
I appreciate any insight or tips. Thank you so much.
Steps to reproduce
---
title: "Testing renderPlotly with shiny::validate()"
format: dashboard
server: shiny
---
```{r}
#| label: setup
library(shiny)
library(plotly)
library(ggplot2)
```
```{r}
sliderInput("min_mpg", "Minimum MPG:", min = 10, max = 30, value = 15)
plotlyOutput("myPlot")
```
```{r}
#| context: server
output$myPlot <- renderPlotly({
# Validate that the input value is within an acceptable range
validate(
need(input$min_mpg >= 10 && input$min_mpg <= 25,
"Please select a minimum MPG between 10 and 25.")
)
# Filter data based on the validated input
filtered_mtcars <- mtcars[mtcars$mpg >= input$min_mpg, ]
# Create a ggplot object
p <- ggplot(filtered_mtcars, aes(x = wt, y = mpg)) +
geom_point() +
labs(title = paste("Cars with MPG >= ", input$min_mpg))
# Convert ggplot to plotly
ggplotly(p)
})
```
Actual behavior
When the user input, input$min_mpg, exceeds the range of valid inputs set by validate() (10 to 25 in this example), renderPlotly() will display the previous, outdated plot like so:
Expected behavior
What I expected was for renderPlotly() to respect all the parameters set by validate(), which means that it should've displayed the specified error message when it detected that input$min_mpg was an invalid input over 25 like so:
Your environment
-IDE: RStudio 2024.09.1+394
-OS: MacOS Sequoia 15.6.1
Quarto check output
Quarto 1.8.26
[✓] Checking environment information...
Quarto cache location: /Users/ac3656/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.6.3: OK
Dart Sass version 1.87.0: OK
Deno version 2.3.1: OK
Typst version 0.13.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.8.26
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Tex: (not detected)
[✓] Checking Chrome Headless....................OK
Using: Chrome found on system
Path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Source: MacOS known location
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.9.6
Path: /Library/Developer/CommandLineTools/usr/bin/python3
Jupyter: 5.7.2
Kernels: python3
(|) Checking Jupyter engine render....Traceback (most recent call last):
File "/Applications/quarto/share/jupyter/jupyter.py", line 20, in <module>
from notebook import notebook_execute, RestartKernel
File "/Applications/quarto/share/jupyter/notebook.py", line 15, in <module>
from yaml import safe_load as parse_string
ModuleNotFoundError: No module named 'yaml'
There is a requirements.txt file in this directory. Is this for a venv that you need to restore?
WARN: Error encountered when rendering files
[✓] Checking Jupyter engine render....OK
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from quarto-dev/quarto-cli
-
binder bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
quarto-dev/quarto-cli#14907 · 3 comments ·
-
brand bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
quarto-dev/quarto-cli#14891 ·
-
brand bug html revealjs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
quarto-dev/quarto-cli#14882 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
quarto-dev/quarto-cli#14875 ·
-
Percent scripts: accept raw-string (r""") and '''-delimited markdown cells, as jupytext writes them Openengines-jupyter enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
quarto-dev/quarto-cli#14850 · 2 comments ·
All issues in quarto-dev/quarto-cli
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy-website#2595 ·