Problem/Motivation

There is a bug when using CAPTCHA module with USWDS. When I click the "Get new captcha!" link, it does not refresh the image CAPTCHA.

Steps to reproduce

With USWDS base theme enabled

  1. Install CAPTCHA
  2. Enable CAPTCHA and Image CAPTCHA
  3. Enable an image CAPTCHA on any page here: /admin/config/people/captcha/captcha-points
    • For example, on Drupal's built in User Log In page
  4. Go to the page with the CAPTCHA and poke the "Get new captcha!" link
  5. New captcha does not appear, page does not change
  6. Right click on link and open in a new tab shows that correct json data is being produced, but it just doesn't update the page
  7. Disable USWDS base theme and the "Get new captcha!" link works again
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

leraa created an issue. See original summary.

leraa’s picture

I've discovered the problem. It is in this template:

/themes/contrib/uswds_base/templates/form/details.html.twig

If I replace the contents of this template with the same template from Bartik/Classy, it functions correctly. I'm trying to narrow down the exact breaking markup right now.

mferanda’s picture

Thank you for your help!

Are you able to see anything specific? While I can’t really support a non core issue (using captchas), if you find a mistake with the template then we’ll definitely look at resolving. Especially if it wouldn’t cause a problem necessarily to others using this theme.

Personally, I dont use captchas with Federal sites... they’re never going to be 508 compliant. Basically then the form is no longer accessible to vision impaired.

leraa’s picture

Well, I'm trying to find out which particular thing in that template is breaking it. I think it's the assignment of classes. I'll report back here when I'm certain.

I'm not a big fan of captchas either, but unfortunately not in a position to change their use here.

I'm starting to think that a primary problem is that the template in question is the template for the <details> element. It's expecting a <details> html element to be present if the details template is used. But the USWDS template completely removes any use of the <details> element. It takes it out and replaces it with list markup.

So anything that is using the details template and expecting/needing <details> to be there is going to break.

leraa’s picture

I had to rip out the <ul>-based markup to get this to work finally.

I've attached two files, the original for the convenience of comparing, and my new template with the altered markup. I had to relabel them as txt because twig files are not allowed here.

The altered markup did not require having a <details> element for CAPTCHA to work. That theory was wrong. But it did require the ul/li layout to be abandoned.

Hope this helps.

mferanda’s picture

Sounds like still an issue you can resolve in your own subtheme and custom the twig file.

That’ll at least resolve your issue. I’ll take a look further before moving on with 2.10 to see if i find something. Will release a beta2 if so.

mferanda’s picture

I'm going to have to mark this item as things working as intended. Basically, I can't see an easy path forward other than custom manipulation for a different module. This falls into something where it's not USWDS itself, but sites can adjust their own needs as necessary.

Items adjusting uswds_base should only be for Drupal Core items and/or USWDS itself.

mferanda’s picture

Status: Active » Closed (works as designed)