Support » Plugin: Genesis Accessible » searchinput element does not have a name available to an accessibility API

  • Bozz

    (@bozzmedia)


    Using the HTML_CodeSniffer tool I pick up this error on both a site I’m working on and the website for this plugin:

    This searchinput element does not have a name available to an accessibility API. Valid names are: label element, title undefined, aria-label undefined, aria-labelledby undefined.

    When I look at the code in the plugin I notice it has this in include/forms.php,

    		$form .= sprintf(
    			'<meta itemprop="target" content="%s"/><label for="%s">%s</label><input itemprop="query-input" type="search" name="s" id="%s" %s="%s" /><input type="submit" value="%s" /></form>',

    however it is not printed in the source when I’m testing on the frontend, it looks like:

    <form class="search-form" itemprop="potentialAction" itemscope="" itemtype="https://schema.org/SearchAction" method="get" action="https://website.org/" role="search"><input class="search-form-input" type="search" name="s" id="searchform-5c0f6bb3a0a533.88678965" placeholder="Search"><input class="search-form-submit" type="submit" value="Search"><meta itemprop="target" content="https://website.org/?s={s}"></form>

    Any thoughts on what might be going on there? I would think this is a false positive but I also notice no label elements in the markup. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    I am guessing you are using Genesis 2.7.1–is that correct? At this point, if you are using a current version of Genesis, the search form is actually being output by the Genesis Framework, not this plugin, which just enables the framework’s accessibility features.

    Unfortunately, this is an error which was introduced in Genesis 2.7. The error has been resolved in the framework, but I don’t know when the update will be released.

    If you are comfortable adding some code to your site, you can add this to fix the issue for now:

    
    add_filter( 'genesis_search_form_label', 'prefix_fix_search_label' );
    /**
     * Fix the missing label element for the search form.
     * 
     * @param $label
     *
     * @return string
     */
    function prefix_fix_search_label( $label ) {
    	if ( $label ) {
    		return $label;
    	}
    
    	return __( 'Search this website', 'genesis' );
    }
    

    If you choose to use this, please make sure you have a backup of your files and practice safe coding. Thank you for raising the issue!

    Bozz

    (@bozzmedia)

    Thanks for the super fast response and fix!

    Great guess, yes we are running 2.7.1. Glad it’s fixed in a future update to the framework. Thanks for the excellent support!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘searchinput element does not have a name available to an accessibility API’ is closed to new replies.