[wp-trac] [WordPress Trac] #42057: Add ability to pass a label for the <form> element returned by get_search_form()

WordPress Trac noreply at wordpress.org
Sun Oct 1 16:42:05 UTC 2017


#42057: Add ability to pass a label for the <form> element returned by
get_search_form()
---------------------------+-----------------------------
 Reporter:  williampatton  |      Owner:
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:  4.8.2
 Severity:  normal         |   Keywords:
  Focuses:  accessibility  |
---------------------------+-----------------------------
 When more than a single landmark of the same type appears on page it
 should be labeled so that screen readers can announce it in a descriptive
 way to users. Currently the default markup of `get_search_form();` returns
 HTML with landmark `role="search"` without a label (or option to add a
 label). If 2 calls to `get_search_form();` are made then adding the roles
 without options for labels limits their usefulness.

 When reviewing themes I see multiple calls on the same page often. Most
 commonly it's when someone rolls their own custom search feature (for
 example a search icon in navbar that brings a search form into view when
 toggled) is paired with a search widget in the sidebar. There are other
 situations where more than a single call to `get_search_form();` may be
 made.

 My proposal is to allow an args array to be passed to `get_search_form();`
 so that a label could be defined and attached to the `<form>` element and
 screen readers can properly announce each search form independently.

 In this proposal I do not suggest a default as announcing 'Search 1',
 'Search 2' etc is only marginally more useful than simply announcing the
 role itself. There is a previous chanset regarding adding an incremental
 counter which could be used as a default when no label was passed which
 may well be worthwhile to look into and merging both into a single change.
 https://core.trac.wordpress.org/changeset/23801

 Additional Notes: There is a backwards compatibility issue involved with
 this suggested change. I believe I can add this feature and ensure no
 changes are required on the end user part to keep old calls functional.
 Patch to be forthcoming.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42057>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list