Skip to content

Commit 6389a61

Browse files
committed
[#2379] Made Search feedback notification focusable for screenreaders
1 parent abc196e commit 6389a61

File tree

7 files changed

+23
-7
lines changed

7 files changed

+23
-7
lines changed

src/open_inwoner/cms/cases/tests/test_htmx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def mock_upload(request, context):
594594
upload_form = page.locator("#document-upload")
595595
file_input = upload_form.get_by_label("Sleep of selecteer bestanden")
596596
submit_button = upload_form.get_by_role("button", name=_("Upload documenten"))
597-
notification_list = page.get_by_role("alert").get_by_role("list")
597+
notification_list = page.locator(".notification").get_by_role("list")
598598
notification_list_items = notification_list.get_by_role("listitem")
599599
file_list = page.get_by_role("list").last
600600
file_list_items = file_list.get_by_role("listitem")

src/open_inwoner/components/templates/components/Form/Error.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="notifications notifications__errors">
55
<div class="notification notification--warning">
66
{% icon icon="warning_amber" icon_position="before" outlined=True %}
7-
<div class="notification__content">
7+
<div class="notification__content" tabindex="-1">
88
<p class="utrecht-paragraph utrecht-paragraph--oip utrecht-paragraph--oip-compact">{{ message.message }}</p>
99
</div>
1010
</div>

src/open_inwoner/components/templates/components/Notification/Notification.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{% load i18n utils button_tags icon_tags button_tags icon_tags %}
2-
<div class="notification{% if contents %} notification--contents{% endif %}{% if type %} notification--{{ type }}{% endif %}{% if compact %} notification--compact{% endif %} {% if ctx %}notification--{{ ctx }}{% endif %}" role="alert">
2+
<div class="notification{% if contents %} notification--contents{% endif %}{% if type %} notification--{{ type }}{% endif %}{% if compact %} notification--compact{% endif %} {% if ctx %}notification--{{ ctx }}{% endif %}">
33
{% if not icon == False %}
44
<div class="notification__icon">
55
{% icon icon outlined=True %}
66
</div>
77
{% endif %}
88

9-
<div class="notification__content">
9+
<div class="notification__content" tabindex="-1">
1010
{% if title %}<h2 class="utrecht-heading-2">{{ title }}</h2>{% endif %}
1111
{% if notification %}<p class="utrecht-paragraph">{{ notification }}</p>{% endif %}
1212
{% if action %}{% button href=action text=action_text %}{% endif %}

src/open_inwoner/js/components/notifications/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@ export class Notification {
2525
}
2626

2727
/**
28-
* Scrolls to the notification content.
28+
* Scrolls to the notification content and sets focus.
2929
*/
3030
scrollToNotification() {
31-
const notificationContent = document.querySelector('.notification__content')
31+
const notificationContent = this.node.querySelector(
32+
'.notification__content'
33+
)
3234

3335
if (notificationContent) {
3436
// If errors are present, scroll and trigger the opened state
3537
notificationContent.scrollIntoView({
3638
block: 'center',
3739
behavior: 'smooth',
3840
})
41+
// Set focus for screen readers
42+
notificationContent.focus()
3943
}
4044
}
4145

src/open_inwoner/scss/components/Grid/Grid.scss

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
}
3636
}
3737
}
38+
39+
/// Search grid
40+
&--search {
41+
display: flex;
42+
flex-direction: column;
43+
}
3844
}
3945

4046
&--limit &__sidebar,

src/open_inwoner/scss/components/Notification/_Notification.scss

+6
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
& &__content {
102102
margin-top: var(--spacing-tiny);
103103

104+
&:focus,
105+
&:focus-visible {
106+
outline: none;
107+
border: none;
108+
}
109+
104110
& * {
105111
margin: 0;
106112
}

src/open_inwoner/templates/pages/search.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h2 class="utrecht-heading-2">{% trans "Zoekfilters" %}</h2>
2828
{# end search filters #}
2929
</aside>
3030

31-
<div class="grid__main">
31+
<div class="grid__main grid__main--search">
3232
{% if paginator.count %}
3333
<div class="search-results">
3434
<h2 class="utrecht-heading-2 search-results__title">

0 commit comments

Comments
 (0)