Repository navigation
Expose screening results to custom form components - #574
Merged
Merged
Conversation
Clicking Form Editor forced a full screener refetch to pick up benefit changes, which hid the tabs behind a spinner on every visit and only refreshed that one tab. Benefit list loads now update the editor's cached screener directly, so every tab sees current benefits without a network round trip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The published and preview renderers each looked up the service and created the same effect. A shared connectScreeningResults helper keeps future changes to what reaches custom fields in one place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a failed evaluation the snapshot stayed pending with nothing to distinguish it from a request in flight, so fields showing an updating state would wait indefinitely. The snapshot now carries a failed flag from the published screener and preview, cleared when an evaluation succeeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
useScreeningResults looked up its service strictly, so any form built without screeningResultsModule failed to render with "No provider for screeningResults". The hook now falls back to an empty snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Samples took their outcome from each configured benefit's position, so a screener with one or two benefits never showed an ineligible or undecided sample in the editing canvas. Clearly named examples now fill in any outcome the configured benefits don't cover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The snapshot froze only its top level, so a field that sorted or annotated results in place changed the parent's signal value without notifying it, letting the results panel and question hiding drift from the API response. Live results are now deep-copied and deep-frozen once per evaluation, and editor samples are frozen too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Custom form-js fields can now read screening results through a per-form service and reactive Preact hook in published screeners, preview, and the editor canvas. This provides the shared results interface for the upcoming Next steps and Print summary components.
Closes #555. Third PR for #552, following #573. The Next steps component follows in #556.
The service exposes the latest results, pending state, and evaluation failures. It retains previous results while the latest answers are pending, including debounce and failed requests; the parent screening flows continue rejecting stale responses. Fields receive frozen copies, and updates neither import schemas nor submit answers. Service instances are isolated between forms, and fields render an empty snapshot when the module is unavailable.
Editor samples use configured benefit IDs and names, with clearly named examples filling any missing eligible, ineligible, or undecided outcomes. Benefit list loads update the editor's cached benefits without an extra tab-switch fetch or loss of unsaved form changes. Samples stay outside answers and saved schemas.
The hook uses the viewer's shared
FormContextanduseSyncExternalStore, since form-js 1.15's exporteduseServiceuses an editor-only context. Integration tests exercise actual custom Preact fields in both live renderers and the editor canvas.Validation:
git diff --checkpassed.