Add Turnstile functionality and fallback support - #17
Conversation
shinesoftware
commented
Nov 24, 2025
- 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.
|
Please merge the changes so I can use them into our project, thanks for your help! |
- 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.
|
|
Can't merge as-is though:
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 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. |


