Page MenuHomePhabricator

hCaptcha VisualEditor: Load hCaptcha secure-api.js when user interacts with edit form
Closed, ResolvedPublic1 Estimated Story Points

Description

Summary

We want to load the hCaptcha scripts when a user interacts with the VisualEditor edit form, when we know that the user will need to complete hCaptcha before they start to make their edit.

Background

  • ConfirmEdit (CAPTCHA extension) has a hCaptcha VisualEditor plugin that handles displaying the hCaptcha challenge in the edit summary window
    • This is displayed if the visualeditoredit fails with a captcha requirement being hcaptcha
    • Therefore, the user will have to press "Save changes", then complete hCaptcha, and then press "Save changes" again
  • This is not an ideal flow, and instead we want to be able to load the hCaptcha SDK earlier
    • We can load the hCaptcha SDK when the user starts interacting with any field on the edit form, like in the wikitext editor
      • Because the VisualEditor "textarea" isn't actually an input element, this doesn't work out of the gate and we may need to handle VisualEditor methods to listen to when a user starts interacting with the field

Technical notes

  • We need some code that listens for when a user starts interacting with the edit field in the VisualEditor edit source mode
    • If this happens then the code should check that hCaptcha will need to be completed to complete any edit (i.e. it should not worry about the case where AbuseFilter requires a captcha due a filter being matched)
    • If this is also the case, then the hCaptcha SDK should be loaded
      • We may need to also update the relevant utils.js file to be okay with having loadHCaptcha called multiple times and still just load it once
        • Currently, calling loadHCaptcha more than once will cause the hCaptcha SDK to be loaded each time the method is called

Acceptance criteria

  • When a user interacts with the VisualEditor editing "textarea", the hCaptcha SDK is loaded in the background via a call to loadHCaptcha from utils.js

Event Timeline

Change #1196013 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/ConfirmEdit@master] Update docs for existing VisualEditor hCaptcha handler

https://gerrit.wikimedia.org/r/1196013

Change #1196013 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] Update docs for existing VisualEditor hCaptcha handler

https://gerrit.wikimedia.org/r/1196013

Dreamy_Jazz set the point value for this task to 2.Oct 14 2025, 2:10 PM
Dreamy_Jazz changed the point value for this task from 2 to 1.

Change #1196150 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/ConfirmEdit@master] [Very WIP] Load hCaptcha when user interacts with VisualEditor edit form

https://gerrit.wikimedia.org/r/1196150

Change #1196150 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] VisualEditor: Create hCaptcha on load handler

https://gerrit.wikimedia.org/r/1196150