@canonical/react-components 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Notifications/ToastNotification/Toast.scss +1 -1
- package/dist/components/Notifications/ToastNotification/ToastNotificationList.js +6 -0
- package/dist/esm/components/Notifications/ToastNotification/Toast.scss +1 -1
- package/dist/esm/components/Notifications/ToastNotification/ToastNotificationList.js +7 -1
- package/package.json +1 -1
|
@@ -155,6 +155,12 @@ const ToastNotificationList = _ref => {
|
|
|
155
155
|
|
|
156
156
|
// Only filter input data if there are filters present
|
|
157
157
|
const filteredNotifications = hasFilters ? notifications.filter(notification => filters.has(notification.type)) : notifications;
|
|
158
|
+
(0, _react.useEffect)(() => {
|
|
159
|
+
if (hasFilters && filteredNotifications.length === 0) {
|
|
160
|
+
// if there are no filtered notifications, reset the filters
|
|
161
|
+
setFilters(new Set());
|
|
162
|
+
}
|
|
163
|
+
}, [hasFilters, filteredNotifications]);
|
|
158
164
|
|
|
159
165
|
// Don't assign alert role for notifications when expanded since we don't want
|
|
160
166
|
// screen readers to announce every existing notification
|
|
@@ -3,7 +3,7 @@ import Button from "../../Button";
|
|
|
3
3
|
import Icon from "../../Icon";
|
|
4
4
|
import Notification from "../Notification";
|
|
5
5
|
import { DefaultTitles } from "../Notification/Notification";
|
|
6
|
-
import { useLayoutEffect, useRef, useState } from "react";
|
|
6
|
+
import { useLayoutEffect, useRef, useState, useEffect } from "react";
|
|
7
7
|
import { createPortal } from "react-dom";
|
|
8
8
|
import Animate from "./Animate";
|
|
9
9
|
import { usePrefersReducedMotion } from "../../../hooks";
|
|
@@ -148,6 +148,12 @@ var ToastNotificationList = _ref => {
|
|
|
148
148
|
|
|
149
149
|
// Only filter input data if there are filters present
|
|
150
150
|
var filteredNotifications = hasFilters ? notifications.filter(notification => filters.has(notification.type)) : notifications;
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (hasFilters && filteredNotifications.length === 0) {
|
|
153
|
+
// if there are no filtered notifications, reset the filters
|
|
154
|
+
setFilters(new Set());
|
|
155
|
+
}
|
|
156
|
+
}, [hasFilters, filteredNotifications]);
|
|
151
157
|
|
|
152
158
|
// Don't assign alert role for notifications when expanded since we don't want
|
|
153
159
|
// screen readers to announce every existing notification
|