Skip to content

Commit

Permalink
[#2379] Made Search feedback notification focusable for screenreaders
Browse files Browse the repository at this point in the history
  • Loading branch information
jiromaykin committed Jul 1, 2024
1 parent 451a4e6 commit 450e43d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/open_inwoner/cms/cases/tests/test_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def mock_upload(request, context):
upload_form = page.locator("#document-upload")
file_input = upload_form.get_by_label("Sleep of selecteer bestanden")
submit_button = upload_form.get_by_role("button", name=_("Upload documenten"))
notification_list = page.get_by_role("alert").get_by_role("list")
notification_list = page.locator(".notification").get_by_role("list")
notification_list_items = notification_list.get_by_role("listitem")
file_list = page.get_by_role("list").last
file_list_items = file_list.get_by_role("listitem")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="notifications notifications__errors">
<div class="notification notification--warning">
{% icon icon="warning_amber" icon_position="before" outlined=True %}
<div class="notification__content">
<div class="notification__content" tabindex="-1">
<p class="utrecht-paragraph utrecht-paragraph--oip utrecht-paragraph--oip-compact">{{ message.message }}</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% load i18n utils button_tags icon_tags button_tags icon_tags %}
<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">
<div class="notification{% if contents %} notification--contents{% endif %}{% if type %} notification--{{ type }}{% endif %}{% if compact %} notification--compact{% endif %} {% if ctx %}notification--{{ ctx }}{% endif %}">
{% if not icon == False %}
<div class="notification__icon">
{% icon icon outlined=True %}
</div>
{% endif %}

<div class="notification__content">
<div class="notification__content" tabindex="-1">
{% if title %}<h2 class="utrecht-heading-2">{{ title }}</h2>{% endif %}
{% if notification %}<p class="utrecht-paragraph">{{ notification }}</p>{% endif %}
{% if action %}{% button href=action text=action_text %}{% endif %}
Expand Down
8 changes: 6 additions & 2 deletions src/open_inwoner/js/components/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ export class Notification {
}

/**
* Scrolls to the notification content.
* Scrolls to the notification content and sets focus.
*/
scrollToNotification() {
const notificationContent = document.querySelector('.notification__content')
const notificationContent = this.node.querySelector(
'.notification__content'
)

if (notificationContent) {
// If errors are present, scroll and trigger the opened state
notificationContent.scrollIntoView({
block: 'center',
behavior: 'smooth',
})
// Set focus for screen readers
notificationContent.focus()
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/open_inwoner/scss/components/Grid/Grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
}
}
}

/// Search grid
&--search {
display: flex;
flex-direction: column;
}
}

&--limit &__sidebar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
& &__content {
margin-top: var(--spacing-tiny);

&:focus,
&:focus-visible {
outline: none;
border: none;
}

& * {
margin: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/templates/pages/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h2 class="utrecht-heading-2">{% trans "Zoekfilters" %}</h2>
{# end search filters #}
</aside>

<div class="grid__main">
<div class="grid__main grid__main--search">
{% if paginator.count %}
<div class="search-results">
<h2 class="utrecht-heading-2 search-results__title">
Expand Down

0 comments on commit 450e43d

Please sign in to comment.