mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 20:01:01 -05:00
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.
26 lines
764 B
HTML
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 %}
|