fix/2556 reload button in image captcha mode loads a new challenge#2560
Open
forgetso wants to merge 1 commit into
Open
fix/2556 reload button in image captcha mode loads a new challenge#2560forgetso wants to merge 1 commit into
forgetso wants to merge 1 commit into
Conversation
The reload button used to bounce the user back to the checkbox: the modal closed and never re-opened to show the fresh challenge. `Manager.reload` called `resetState(frictionlessState?.restart)`, which (on the bundle path) restarted the entire frictionless flow by re-keying the ProcaptchaFrictionless wrapper, unmounting the image captcha widget. On the direct path it synchronously set `showModal: false`. Either way the modal disappeared. `reload` now just clears the active timeout, fires `onReload`, resets the loading flag so `start()` won't no-op against a stale `loading: true`, and calls `start()` to request a fresh challenge using the existing frictionless session (if any). The modal stays open through the transition. Adds vitest infrastructure for the @prosopo/procaptcha package and tests covering: onReload firing, start() being invoked, no frictionless restart, modal staying open, timeout being cleared, and the loading-guard being cleared so start() proceeds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4653ff3 to
be256ea
Compare
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.
Summary
Fixes #2556 — the reload button in image captcha mode used to bounce the user back to the checkbox: the modal closed and never reopened with a fresh challenge.
Manager.reloadcalledresetState(frictionlessState?.restart), which on the bundle path restarts the entire frictionless flow by re-keying theProcaptchaFrictionlesswrapper, unmounting the image captcha widget. On the direct path it synchronously setshowModal: false. Either way the modal disappeared.reloadnow clears the active timeout, firesonReload, resets the loading flag sostart()won't no-op against a staleloading: true, and callsstart()to request a fresh challenge using the existing frictionless session (if any). The modal stays open through the transition.reloadbody@prosopo/procaptchaTest plan
npm run -w @prosopo/procaptcha test— 6/6 passnpm run -w @prosopo/procaptcha build:tscnpm run -w @prosopo/procaptcha-react build:tscnpm run -w @prosopo/procaptcha-frictionless build:tscnpm run -w @prosopo/procaptcha-bundle build:tscnpm run -w @prosopo/procaptcha-common testnpm run -w @prosopo/procaptcha-frictionless test🤖 Generated with Claude Code