Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1340546

    Error is: “Form elements do not have associated labels”
    Lighthouse Device Mode: Desktop and Mobile
    See this page (new window).

    Error details
    Reported in Accessibility
    Failing Elements: textarea#comment

    This is the HTML for the Comment form:

    <p class="comment-form-comment">
    <label for="comment">Comment <span class="required" aria-hidden="true">*</span></label>
    <textarea autocomplete="new-password" id="comment" name="ac76510e77" cols="45" rows="8" maxlength="65525" required="required"></textarea>
    <textarea id="a82a363e89a4c00b08eb9a1b38b128a0" aria-hidden="true" name="comment" autocomplete="new-password" style="padding:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;position:absolute !important;white-space:nowrap !important;height:1px !important;width:1px !important;overflow:hidden !important;" tabindex="-1"></textarea>
    ...
    </p>

    I’m not an HTML expert but it appears to me that there IS a label on the comments form, which implies this is a Lighthouse error, not Enfold. My guess might be that it’s processing ‘textarea’ incorrectly, as the Help (https://web.dev/label/?utm_source=lighthouse&utm_medium=devtools) talks about a label on ‘input’, not ‘textarea’.

    If so, then maybe you or the devs should report this to Google to get it fixed otherwise it’s going to keep coming up as an ‘Enfold error’ as Lighthouse and Core Web Vitals gets wider exposure.

    Or is there a way to fix this from your side?

    #1340628

    Hey zimbo,

    Thank you for the inquiry.

    Lighthouse might be referring to the hidden textarea, which is used to prevent spam and bots from autofilling the form. This field doesn’t require a label because it is hidden, so the lighthouse warning can be ignored.

    <textarea id="a82a363e89a4c00b08eb9a1b38b128a0" aria-hidden="true" name="comment" 
    

    Best regards,
    Ismael

    #1340748

    “… the lighthouse warning can be ignored.”

    But it’s flagging this as a red triangle “high priority to fix” error and it is downgrading the Accessibility score.

    Whilst you say the element doesn’t require a label, could one not be added so that the error goes away? It seems a simple fix for the devs to do and I assume it wouldn’t ‘hurt’ or cause a problem, with the benefit of helping the score improve.

    #1340857

    Hi,

    Thank you for the following up.

    We have checked the comment form on a fresh installation without a plugin and we didn’t find the same hidden textare below the actual comment field, so the textarea in your installation must have been added by a custom script or a third party plugin. Did you install a spam protection plugin?

    If you want to adjust the form fields in the comment form manually, you can use the comment_form_defaults filter.

    // https://developer.wordpress.org/reference/hooks/comment_form_defaults/

    Best regards,
    Ismael

    #1340915

    I use Antispam Bee on that site. If I deactivate it then the line
    <textarea id="a941a68d79d5a981230e419af11a14d5" aria-hidden="true" name="comment" autocomplete="new-password" style="padding:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;position:absolute !important;white-space:nowrap !important;height:1px !important;width:1px !important;overflow:hidden !important;" tabindex="-1"></textarea>
    disappears from the page.

    However… without that plugin active, and after a hard cache refresh, I still get the “Form elements do not have associated labels” error from Lighthouse, specifying this line:
    <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea>
    which is the Enfold comment box.

    If I re-enable the plugin the Antispam code re-appears. If I run Lighthouse again, I still get the ‘no label’ error. When Lighthouse highlights what’s causing the error, it states:

    Failing Elements
    textarea#comment

    with a small thumbnail of the comment box. The ‘textarea#comment’ is a hyperlink to the code it thinks is a problem. If you click on that hyperlink, you get transferred to the Elements tab of Dev Tools, wherein the HTML code is displayed. It then automatically goes to the line of ‘problem’ code and highlights it in light blue. Guess what? It’s not the Antispam Bee line that’s highlighted, but the Enfold comment box, e.g.
    <textarea autocomplete="new-password" id="comment" name="ac76510e77" cols="45" rows="8" maxlength="65525" required="required"></textarea>

    So Lighthouse is saying it’s not Antispam Bee causing the error, but Enfold. When Lighthouse detects multiple errors on a page, e.g. ALT tags missing, it lists out all failing instances under Failing Elements. The only element ‘failing’ here is the Enfold textarea.

    When you say “We have checked the comment form on a fresh installation without a plugin and we didn’t find the same hidden textare below the actual comment field“, yes the hidden textarea won’t be there – but did you run Lighthouse on that page? I suspect if you did, you’d get the ‘no label’ error.

    Or you can try it yourself on the page (or any page on my site) that I referenced in the first post.

    Given your last reply, I’m at a loss to understand what’s going on here. Another Lighthouse bug perhaps?

    #1341063

    Hi,

    However… without that plugin active, and after a hard cache refresh, I still get the “Form elements do not have associated labels” error from Lighthouse, specifying this line:

    The default comment field has a corresponding label above it.

    <label for="comment">Comment <span class="required" aria-hidden="true">*</span></label>
    

    So Lighthouse is saying it’s not Antispam Bee causing the error, but Enfold..

    Please note that the comment field is a default WordPress element, it is not generated by the theme.

    If I re-enable the plugin the Antispam code re-appears. If I run Lighthouse again, I still get the ‘no label’ error. When Lighthouse highlights what’s causing the error, it states:

    Are you sure that the textarea that the plugin generates has been removed from the page when you run the test again? Please disable the plugin again, make sure to purge the cache and check if the hidden textarea is actually gone. Or try to run the test using a different browser.

    Best regards,
    Ismael

    #1341170

    Hi Ismael,

    1. The default comment field has a corresponding label above it.
    <label for=”comment”>Comment <span class=”required” aria-hidden=”true”>*</span></label>

    I know, I can see it – but this is the crux of the problem. We can both see the label code is present but Lighthouse says it isn’t, and is generating an error.

    2. Please note that the comment field is a default WordPress element, it is not generated by the theme.
    I did not realise this – please see my last comment below.

    3. Are you sure that the textarea that the plugin generates has been removed from the page when you run the test again?
    Yes, definitely gone, also checked in Firefox. See https://imgur.com/gallery/ZkOGgrv – this is Dev Tools Elements after I have clicked on the hyperlink from Failing Elements > textarea#comment, showing what Lighthouse thinks is the (shaded) line of code that generates the “Form elements do not have associated labels” error.

    Now… given your reply to 2, whilst I appreciate your time and effort to assist with this, isn’t this something that I should (now) be raising on a WordPress forum? You having pointed out it’s a default WP element that is causing the error, and not an Enfold element. Or rather, I think it’s Lighthouse that has a bug here but it’s a WP element it’s failing on. Perhaps I should be getting them to address the issue with Google?

    #1341283

    Hi,

    Yes, opening a thread on a general WordPress forum or directly forwarding this thread to the developers should help. Please note that web tools such as Lighthouse are not perfect so from time to time, results could contain false positives or they could point out errors that are not actually there. If you want to report this specific problem to the developers, please open an issue in this link.

    // https://github.com/google/WebFundamentals/issues

    Thank you for your patience.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.