mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-30 20:27:30 -04:00
Autofocus now optional for live_search
This change has been made because autofocus has been confusing to users of screenreaders because they orient themselves by what is in focus. Moving it when the page loads without warning can cause confusion and mean they miss parts of the page before the point focus has moved to. So now we will only turn on autofocus if there are no other elements in the page that need attention than the search box.
This commit is contained in:
@@ -1,21 +1,25 @@
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
|
||||
{% macro live_search(
|
||||
target_selector=None,
|
||||
show=False,
|
||||
form=None,
|
||||
label=None
|
||||
label=None,
|
||||
autofocus=False
|
||||
) %}
|
||||
{%- set search_label = label or form.search.label.text %}
|
||||
|
||||
{%- set param_extensions = {
|
||||
"label": {"text": search_label},
|
||||
"autocomplete": "off",
|
||||
} %}
|
||||
|
||||
{% if autofocus %}
|
||||
{% set x=param_extensions.__setitem__("attributes", {"data-module": "autofocus"}) %}
|
||||
{% endif %}
|
||||
|
||||
{% if show %}
|
||||
<div data-module="autofocus">
|
||||
<div class="live-search js-header" data-module="live-search" data-targets="{{ target_selector }}">
|
||||
{{ form.search(param_extensions={
|
||||
"label": {"text": search_label},
|
||||
"autocomplete": "off"
|
||||
}) }}
|
||||
{{ form.search(param_extensions=param_extensions) }}
|
||||
<div role="region" aria-live="polite" class="live-search__status govuk-visually-hidden"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
Reference in New Issue
Block a user