-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♿ [#2379] Search feedback notification for screenreaders #1280
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 9 additions & 2 deletions
11
src/open_inwoner/components/templates/components/Notification/Notification.html
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
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
/** | ||
* 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() | ||
jiromaykin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, 100) | ||
} | ||
} | ||
} | ||
|
||
// Start! | ||
|
||
const notificationContents = document.querySelectorAll('.notification__content') | ||
|
||
// Instantiate notifications section | ||
document | ||
.querySelectorAll(NotificationsList.selector) | ||
.forEach((notifications) => new NotificationsList(notifications)) | ||
|
||
// Focus only 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,12 @@ | |
} | ||
} | ||
} | ||
|
||
/// Search grid | ||
&--search { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
} | ||
|
||
&--limit &__sidebar, | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notificationContents
behaves like a stack, so this will srcoll into the last notification (because it was the last one added). If you want to start with the first notification, you need to loop in reverse (so -1 instead of 0).I don't know what's the intended (or best) behavior, though. If you want to focus on the last notification, you can ignore this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pi-sigma Actually no. If you would manually add multiple templates for notifications by hand (after doing Git pull and rebuild NPM), you can see the reverse is not needed.
The code correctly targets the first notification content by using
this.notificationContents[0]
.There is no need to loop in reverse or use a different index. The code already achieves the intended behavior of scrolling to and focusing on the first notification, because I am "re-indexing the Nodelist" here.
If you want to visually see which 1 element truly has focus after PageReload, you can adjust/remove the
_Notification.SCSS
in this PR where I removed the browsers default focus-visible style.You can test this manually this way: paste in multiple types of notifications in the wrong order, after the last line of the
Notification.html
template, so you can see the re-ordering and focus is happening correctly and generate these notifications by using the "Feedback versturen" button after doing a Search query: