Skip to content

fix(js): ImageOutput shows errors and uses the renderer's alt text - #332

Open
schloerke wants to merge 2 commits into
schloerke/output-value-nullfrom
schloerke/image-output-error
Open

schloerke wants to merge 2 commits into
schloerke/output-value-nullfrom
schloerke/image-output-error

Conversation

@schloerke

@schloerke schloerke commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes posit-dev/shinyreact#327.

  • When the render function errors, <ImageOutput> now hides the last image and shows the error message, like a regular plotOutput(). The message div gets the same classes Shiny's renderError() adds (shiny-output-error, shiny-output-error-<type>), so Shiny's own CSS styles it. The image comes back when a value arrives again.
  • The <img> alt now comes from renderPlot(alt =) / @render.plot(alt=) instead of a hardcoded "".

R sends a one-class error type as a plain string rather than an array, so the class list handles both shapes, the same way Shiny's asArray() does.

Silent errors (req()) still show the loading placeholder, since they arrive as a null value, not an error.

@schloerke
schloerke added this pull request to stack #335 November 9, 2026 18:21
@schloerke
schloerke force-pushed the schloerke/image-output-error branch from f1ebbb4 to 176fb9d Compare November 9, 2026 21:41
An erroring render function left the last image on screen with no message.
ImageOutput now swaps the image for the error message, with the same
shiny-output-error classes Shiny's renderError() adds. The <img> alt comes
from renderPlot(alt =) / @render.plot(alt=) instead of a hardcoded "".

Fixes #327
@schloerke
schloerke force-pushed the schloerke/image-output-error branch from 176fb9d to fbbfd7f Compare November 12, 2026 16:08

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

ImageOutput keeps a stale image on error and ignores renderPlot(alt =)

1 participant