No Code Attached Yet a11y
avatar hans2103
hans2103
10 Apr 2024

Steps to reproduce the issue

When declaring a field with type = radio and layout = joomla.form.field.radio.switcher you end up with an inproper use of the for attribute in the label.

The following block of code is the copied HTML of the Featured toggle on the edit page of an com_content item.

<div class="control-group">
    <div class="control-label">
        <label id="jform_featured-lbl" for="jform_featured">
            Featured
        </label>
    </div>
    <div class="controls">
        <fieldset id="jform_featured">
            <legend class="visually-hidden">
                Featured
            </legend>
            <div class="switcher">
                <input type="radio" id="jform_featured0" name="jform[featured]" value="0" checked="" class="active ">
                <label for="jform_featured0">No</label>
                <input type="radio" id="jform_featured1" name="jform[featured]" value="1">
                <label for="jform_featured1">Yes</label>
                <span class="toggle-outside">
                    <span class="toggle-inside"></span>
                </span>
            </div>
        </fieldset>
    </div>
</div>

Elements that can be associated with a <label> element include <button>, <input> (except for type="hidden"), <meter>, <output>, <progress>, <select> and <textarea>.

According to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label

Expected result

In this case the legend fills the need for an accessible label so I think you could just remove the label element and leave it as a div or span.

Actual result

System information (as much as possible)

Additional comments

avatar hans2103 hans2103 - open - 10 Apr 2024
avatar joomla-cms-bot joomla-cms-bot - change - 10 Apr 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 10 Apr 2024
avatar Quy Quy - change - 10 Apr 2024
Labels Added: a11y
avatar Quy Quy - labeled - 10 Apr 2024
avatar brianteeman
brianteeman - comment - 10 Apr 2024

If I remember correctly the control-label element (which includes the label) exists because of the way that we often render fields without using a layout so it was maintained in the layout otherwise the page layout is broken.

badly explained but I hope that helps

avatar hans2103
hans2103 - comment - 11 Apr 2024

If I remember correctly the control-label element (which includes the label) exists because of the way that we often render fields without using a layout so it was maintained in the layout otherwise the page layout is broken.

badly explained but I hope that helps

correct... think we have to add PHP logic to conditional use <label> or just a <div> instead.
Adding complexity to solve invalid use of HTML.

avatar brianteeman
brianteeman - comment - 11 Apr 2024

Adding complexity to solve invalid use of HTML.

is it worth it?

avatar hans2103
hans2103 - comment - 11 Apr 2024

Good question.
Only worth if we want 100% proper HTML. This issue does not cause any harm if we leave it as is.

avatar dgrammatiko
dgrammatiko - comment - 13 Apr 2024

FWIW browsers rolling a new element 'switch', more info here: https://webkit.org/blog/15054/an-html-switch-control/

avatar hans2103
hans2103 - comment - 14 Apr 2024

FWIW browsers rolling a new element 'switch', more info here: https://webkit.org/blog/15054/an-html-switch-control/

That's a nice new attribution. From which % of global users, according to caniuse.com, will Joomla make the jump?

avatar chmst
chmst - comment - 15 Sep 2024

Only worth if we want 100% proper HTML. This issue does not cause any harm if we leave it as is.

Just got the error when checking a form with WAVE and IBM accessibility assessment, both mark it as Error. Probably a screnreader will read the label twice.
EDIT: I used an own overlay for a checkbox, so this is not relevant here.

But we should keep an eye on this.

Add a Comment

Login with GitHub to post a comment