Skip to content

Add Turnstile functionality and fallback support - #17

Open
shinesoftware wants to merge 8 commits into
Pixel-Open:masterfrom
shinesoftware:master
Open

Add Turnstile functionality and fallback support#17
shinesoftware wants to merge 8 commits into
Pixel-Open:masterfrom
shinesoftware:master

Conversation

@shinesoftware

Copy link
Copy Markdown
  • Implemented methods in Turnstile block to check if Turnstile is enabled, retrieve site key, and manage form settings.
  • Enhanced turnstile.phtml to utilize new block methods for configuration and added fallback for themes without Knockout.js.
  • Introduced fallback.js to handle rendering when Knockout.js is unavailable.
  • Updated CSS for improved styling of Turnstile elements.
  • Included fallback.js in the layout for frontend integration.

- Implemented methods in Turnstile block to check if Turnstile is enabled, retrieve site key, and manage form settings.
- Enhanced turnstile.phtml to utilize new block methods for configuration and added fallback for themes without Knockout.js.
- Introduced fallback.js to handle rendering when Knockout.js is unavailable.
- Updated CSS for improved styling of Turnstile elements.
- Included fallback.js in the layout for frontend integration.
@shinesoftware

Copy link
Copy Markdown
Author

Please merge the changes so I can use them into our project, thanks for your help!

Shine Software added 7 commits November 24, 2025 20:39
- Added storefront setting for selecting widget rendering mode (Knockout vs Hyvä/Alpine fallback).
- Ensured only one renderer executes at a time to prevent Cloudflare "sitekey object" errors.
- Introduced dedicated fallback container class (`cf-turnstile-manual`) to prevent auto-rendering on Hyvä widgets.
- Enhanced frontend/admin CSS and JS to respect the selected rendering mode.
- Changed package name from shinesoftware/magento-cloudflare-turnstile to pixelopen/cloudflare-turnstile-bundle.
- Refactored error handling in component.js to ensure the error message is displayed only when the site key is missing.
- Cleaned up formatting in turnstile.phtml for better readability.
- Updated the getValue method in component.js to utilize optional chaining when checking if the value is an observable, enhancing code robustness.
- Adjusted CSS rules for `.cf-turnstile-manual` and `.cloudflare-turnstile .cf-turnstile` to improve layout consistency.
- Ensured proper margin and minimum height settings for better visual alignment in both admin and frontend styles.
@sonarqubecloud

Copy link
Copy Markdown

@magentix

Copy link
Copy Markdown
Collaborator

Can't merge as-is though:

Block/Turnstile.php is shared with the admin login/forgot-password blocks, and the new isEnabled()/isFormEnabled() only check the frontend config (isEnabledOnFront(), getFrontendForms()), never the admin ones that already exist in Helper\Config.

Tested it with admin captcha disabled + frontend enabled: the admin login page ends up showing the widget anyway. Same with the new rendering_mode, it's not area-scoped, and fallback.js is only registered on the frontend layout, so switching to fallback mode can leave the admin login captcha rendering an empty, dead container.

Beyond that bug, we'd rather not grow the base module with Hyvä-specific code (extra config, JS, CSS) that's dead weight for the majority of merchants not on Hyvä a separate companion module would be a better fit.

@magentix magentix self-assigned this Aug 21, 2026
@magentix magentix added invalid This doesn't seem right enhancement New feature or request wontfix This will not be worked on labels Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request invalid This doesn't seem right wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants