Skip to content

Commit

Permalink
[#2379] Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jiromaykin committed Jul 1, 2024
1 parent 381aadd commit 468209c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% load i18n button_tags icon_tags button_tags icon_tags notification_tags %}

{% for message in messages %}
<div class="notifications notifications__errors" role="alert" aria-live="assertive">
<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" aria-live="assertive">
<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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load notification_tags string_tags %}

<div class="notifications" role="alert" aria-live="assertive">
<div class="notifications">
{% for message in messages %}
{% with as_markdown=message.extra_tags|is_substring:"as_markdown" %}
{% with local_message=message.extra_tags|is_substring:"local_message" %}
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
2 changes: 1 addition & 1 deletion src/open_inwoner/templates/master.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
{% block header_image %}{% endblock header_image %}

{% block notifications %}
<div class="container container--no-margin" role="alert" aria-live="assertive">
<div class="container container--no-margin">
{% notifications messages closable=True %}
</div>
{% endblock %}
Expand Down

0 comments on commit 468209c

Please sign in to comment.