Problem/Motivation

We currently use "label" instead of "legend" in 'captcha.html.twig'
before

Steps to reproduce

Proposed resolution

Use "legend" HTML element instead of label in 'captcha.html.twig'

after

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork captcha-3365354

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Grevil created an issue. See original summary.

grevil’s picture

Status: Active » Needs review
StatusFileSize
new29.18 KB

Done, please review! See screenshot:
screenshot

anybody’s picture

Assigned: Unassigned » thomas.frobieter
Status: Needs review » Needs work
Related issues: +#3357694: Use label & description for captcha label & description instead of custom structure

We made that change intentionally, as label's have Drupal default styling, while fieldset legend's don't.
See the issue over here: #3357694: Use label & description for captcha label & description instead of custom structure I'm not very motivated to reverse that decision.

But another point was also raised:
@thomas.frobieter mentioned that for the fieldset styling should have further classes for core themes, eventually.

Also, changing the markup might break existing installations (BC), so we have to double-check if this is still allowed in beta.

Assigning @thomas.frobieter to add possible Drupal Core default classes (that won't break things?).

Once 2.0.0 is released, we'll definitely not be allowed to make such changes anymore for a widely used module like this:

Betas for minor and major versions

The goal of the beta phase is to prepare a polished, stable release, and to provide a testing target for theme or module developers and site owners.

We restrict changes during the beta phase in order to reduce disruptions and manage technical debt. New features and APIs must be targeted for the next development minor instead, and public APIs must remain stable.

The release of the first beta is a firm deadline for all feature and API additions. Even if an issue is pending in the RTBC queue when the commit freeze for the beta begins, it will be committed to the next minor release only.

The following types of changes are allowed during the beta phase:

  • criticals
  • bug fixes and contributed project blockers [19 issues], if they are non-disruptive, or if the impact outweighs the disruption
  • API documentation improvements
  • patch- and minor-level library updates
  • string changes
  • user interface changes to fix usability or accessibility issues, if the impact outweighs the disruption
  • minor API additions or internal API changes to fix bugs, if the impact outweighs the disruption
  • changes requiring an upgrade path, if the impact outweighs the disruption
  • Certain other issues with high impact and low disruption at committer discretion only.

https://www.drupal.org/about/core/policies/core-change-policies/allowed-...

anybody’s picture

StatusFileSize
new7.73 KB
anybody’s picture

Issue summary: View changes
anybody’s picture

A good reason for using the legend would be, that some of the captcha implementations use their own label for the captcha input. Others don't.

While our label will never technically collide with them, using legend would 100% separate them in all cases.

I think best will be to compare the outcome in major Drupal themes, and afterwards @thomas.frobieter should have the last word on that. These should be our final (justified breaking) changes to the twig file anyway until 3.x!

grevil’s picture

Priority: Normal » Major

Setting this to major, as it prevents the 2.x release and enables the module for #3365265: Release 2.0.0 to safe folks from wrong versions to apply.

thomas.frobieter’s picture

So, the idea is:
- Use the regular fieldset renderer, so the fieldset.html.twig will be used
- Use the captcha.html.twig only for the fieldset contents

Both are overridable by themes, while getting the default fieldset styles from the (base) theme. So we don't get a ugly unstyled fieldset, like we currently do in for example Claro and Olivero.

This way, the decision to use legend or label ist not up to us, its up the the (base) theme and thats fine.

anybody’s picture

Re #9 ok so let's test this here in the MR, see what the results and pro / con's are and if it takes too much time / isn't worth it. Based on that, we should then decide, how to proceed further. From simple to complex.

Nice ideas for improvement @thomas.frobieter. Anyway, I think we shouldn't invest days and set a justified limit.

If it doesn't work well or is too complex, we can still discuss to switch back to legend - then we definitely need to compare the results in relevant themes.

thomas.frobieter’s picture

Assigned: thomas.frobieter » grevil

I agree, so @Grevil can you please figure out if we are able to use the regular fieldsets, etc. like described in #9? I'll help with the templates, classes etc. if required.

anybody’s picture

One more point: We need to ensure that we have our own theme suggestion just for this fieldset render!

As we don't want to add one for any fieldset, we need to pass it in the render array itself. This seems possible, see: https://www.drupaladventures.com/article/theme-suggestions-theme-render-...

anybody’s picture

Okay... I just wanted to give this a first shot, went into the code and then saw @Grevil's and my pain around all these bloated, decade old structures... especially the several modifications to the array structures plus CAPTCHA implementations relying on these structures. We shouldn't touch it.

Honestly, I don't think the proposed change to fieldsets is possible within hours, not even a day. And it's very risky, as then the fieldset will influence the captcha's array structure technically (the old tree thing...).

I wanted to try, because I see the benefits from what @thomas.frobieter said, but this should be done with or after CAPTCHA rewrite from scratch. This is far above our heads and budgets.

@thomas.frobieter may still decide to make the switch back to legend instead of label, I won't block that, if there are good enough reasons and if it's before 2.0.0.

Someone always has to pay...

thomas.frobieter’s picture

Flip a coin, I don't think its really relevant. Label is better to style, Legend is semantically correct.
Some sites already use the beta release, so they have might already styled it as label. So, lets stick with this.

grevil’s picture

Priority: Major » Minor
Status: Needs work » Postponed

Ok, I guess we can set this postponed to whenever and do a real release?

grevil’s picture

anybody’s picture

Assigned: grevil » Unassigned
neclimdul’s picture

Priority: Minor » Normal
Status: Postponed » Needs work
Issue tags: +WCAG

Not sure what would be postponing work on this so unblocking.

Relevant WCAG rule this would fix. https://www.w3.org/WAI/WCAG21/Techniques/html/H71

anybody’s picture

Good point @neclimdul!

The first element inside the fieldset must be a legend element, which provides a label or description for the group.

https://www.w3.org/WAI/WCAG21/Techniques/html/H71

So let's fix the tests and do this. Who's willing?

anybody’s picture

@neclimdul what do you think about this proposed change? That would also comply with the default and solve issues with #3377448: Google Tag manager is loaded without consent, if no title is used.

anybody’s picture

Status: Needs work » Needs review

@neclimdul what do you think about this proposed change? That would also comply with the default and solve issues with #3377448: Google Tag manager is loaded without consent, if no title is used.

anybody’s picture

Title: Use "legend" HTML element instead of label in 'captcha.html.twig' » Use "legend" HTML element instead of label in 'captcha.html.twig', use div if no title given
anybody’s picture

Re-introduced backwards-compatibility for the structure, if no title is set and if a title is set, improved the markup.
This was planned to be 2.x only, but with #3367503: Difficult migration from Drupal 9 to 10 got into 8.x-1.* which is out of scope here.

grevil’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -WCAG

Nice, tests are all green! RTBC!

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @Grevil, let's merge this into 2.x and keep it there for some days. Also fixing #3375511: 8.x-1.12 shows captcha fieldset, even without captcha output by bringing back the old structure, if no title is given.

  • Anybody committed 87f5efe9 on 2.x authored by Grevil
    Issue #3365354 by Anybody, Grevil: Use "legend" HTML element instead of...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.