Files
notifications-admin/app/templates/components/live-search.html
Pea Tyczynska bd19b1171c 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.
2020-09-24 12:27:10 +01:00

26 lines
764 B
HTML

{% macro live_search(
target_selector=None,
show=False,
form=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 class="live-search js-header" data-module="live-search" data-targets="{{ target_selector }}">
{{ form.search(param_extensions=param_extensions) }}
<div role="region" aria-live="polite" class="live-search__status govuk-visually-hidden"></div>
</div>
{% endif %}
{% endmacro %}