-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2379] Reordered notifications order + forced focus on 1st element
- Loading branch information
1 parent
6389a61
commit 19637ed
Showing
10 changed files
with
134 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/open_inwoner/js/components/notifications/NotificationsList.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Surrounding Notifications class. | ||
* @class | ||
*/ | ||
export class NotificationsList { | ||
static selector = '.notifications' | ||
constructor(notificationContents) { | ||
this.notificationContents = notificationContents | ||
} | ||
|
||
scrollToFirstNotification() { | ||
if (this.notificationContents.length > 0) { | ||
// Scroll to the first notification, since there could be multiple | ||
this.notificationContents[0].scrollIntoView({ | ||
block: 'center', | ||
behavior: 'smooth', | ||
}) | ||
|
||
// Add a delay before setting focus for screen readers | ||
setTimeout(() => { | ||
// Set focus on the first notification content | ||
this.notificationContents[0].focus() | ||
}, 100) // Adjust the delay as necessary | ||
} | ||
} | ||
} | ||
|
||
// Start! | ||
|
||
// Select all notification contents | ||
const notificationContents = document.querySelectorAll('.notification__content') | ||
|
||
// Create instances of NotificationsList for each matching element in the NodeList | ||
document | ||
.querySelectorAll(NotificationsList.selector) | ||
.forEach((notifications) => new NotificationsList(notifications)) | ||
|
||
// Create ScrollManager instance and focus the first notification content | ||
const scrollManager = new NotificationsList(notificationContents) | ||
scrollManager.scrollToFirstNotification() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters