Skip to content

feat(core): forward params to named onSuccess/onError actions - #307

Merged
Railly merged 4 commits into
mainfrom
feat/forward-params-to-named-actions
Jul 8, 2026
Merged

feat(core): forward params to named onSuccess/onError actions#307
Railly merged 4 commits into
mainfrom
feat/forward-params-to-named-actions

Conversation

@Railly

@Railly Railly commented Jul 8, 2026

Copy link
Copy Markdown
Member

onSuccess and onError can run a registered handler by name via { action: "<name>" }, but only the name was forwarded, so params never reached the handler. A chained onSuccess: { action: "toast", params: { message } } silently fell back to the handler's defaults, even though top-level bindings already resolve params. This closes that gap.

Params were dropped in three places, now all fixed:

  • the schema stripped params from the { action } form during validation, on both ActionOnSuccessSchema and ActionOnErrorSchema
  • the core executor forwarded only the name
  • each renderer bridge rebuilt { action: name } from that name (react, solid, vue, react-native, react-pdf, react-email, ink, svelte)

The fix forwards the whole binding: params is added to the { action } form in both schemas and their hand-written types, and the executor passes action.onSuccess / action.onError.

The executeAction context callback is now typed (binding: ActionBinding) instead of (name: string). Core always passes the resolved binding, so this makes the contract honest and lets every renderer bridge collapse to execute(binding). This is a breaking change for anyone implementing a custom renderer bridge that expected a bare string, now surfaced at compile time rather than silently at runtime. navigate and set handlers are unaffected.

Tests: core unit tests cover the executor and both schemas; react and svelte integration tests render a real component, fire the event, and assert the named onSuccess and onError handlers receive their params. Each was verified to fail without the fix.

Closes #301

Named actions in onSuccess/onError only received their name, so params
never reached the handler. Forward the whole binding through the core
executor and every renderer bridge so a named handler receives params
the same way top-level bindings do.

Closes #301
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
json-render Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-chat-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-dashboard-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-game-engine-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-image-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-no-ai Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-react-email-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-react-pdf-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-react-three-fiber-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-remotion-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-solid-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-svelte-chat-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-svelte-demo Ready Ready Preview, Comment Jul 8, 2026 10:22pm
json-render-vue Ready Ready Preview, Comment Jul 8, 2026 10:22pm

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

ActionOnErrorSchema omits the optional params field, so onError action params are silently stripped during Zod validation.

Fix on Vercel

ActionOnErrorSchema omitted the optional params field, so onError
action params were silently stripped during Zod validation even though
the type allowed them. Mirror the onSuccess form and add schema-level
tests for both.
The Svelte ActionProvider bridge rebuilt the sub-binding from the name
only, dropping params, same gap as the other renderers. Its component
script block is type-checked more loosely, so it passed CI while wrong.
Forward the whole binding and add integration tests that named
onSuccess and onError handlers each receive their params.
Core always passes the resolved binding to the executeAction context
callback, so the string half of the union was false back-compat. Drop it
to (binding: ActionBinding): the runtime change becomes a compile error
for anyone with a custom renderer bridge instead of a silent break, and
every bridge collapses to execute(binding).
@Railly
Railly merged commit 9d3dfc8 into main Jul 8, 2026
22 checks passed
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.

[Feature request] forward params to the named handler in onSuccess / onError

2 participants