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 ff0cb2c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
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
11 changes: 8 additions & 3 deletions src/open_inwoner/js/components/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ 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
console.log('there is notificationContent: ', notificationContent)
// If errors are present, scroll, set focus, and trigger the opened state
notificationContent.scrollIntoView({
block: 'center',
behavior: 'smooth',
})
// Set focus to the notification content 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
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 ff0cb2c

Please sign in to comment.