-
Notifications
You must be signed in to change notification settings - Fork 352
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
fix(Notification Drawer): Added screen reader text for notification drawer item read state #9569
Merged
Merged
Changes from all commits
Commits
Show all changes
5 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,6 +13,8 @@ export interface NotificationDrawerListItemProps extends React.HTMLProps<HTMLLIE | |||||
isRead?: boolean; | ||||||
/** Callback for when a list item is clicked */ | ||||||
onClick?: (event: any) => void; | ||||||
/** Visually hidden text that conveys the current read state of the notification list item */ | ||||||
readStateScreenReaderText?: string; | ||||||
/** Tab index for the list item */ | ||||||
tabIndex?: number; | ||||||
/** Variant indicates the severity level */ | ||||||
|
@@ -26,6 +28,7 @@ export const NotificationDrawerListItem: React.FunctionComponent<NotificationDra | |||||
isRead = false, | ||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||||||
onClick = (event: React.MouseEvent) => undefined as any, | ||||||
readStateScreenReaderText, | ||||||
tabIndex = 0, | ||||||
variant = 'custom', | ||||||
...props | ||||||
|
@@ -38,6 +41,14 @@ export const NotificationDrawerListItem: React.FunctionComponent<NotificationDra | |||||
} | ||||||
} | ||||||
}; | ||||||
|
||||||
let readStateSRText; | ||||||
if (readStateScreenReaderText) { | ||||||
readStateSRText = readStateScreenReaderText; | ||||||
} else { | ||||||
readStateSRText = isRead ? 'read' : 'unread'; | ||||||
} | ||||||
|
||||||
return ( | ||||||
<li | ||||||
{...props} | ||||||
|
@@ -52,6 +63,7 @@ export const NotificationDrawerListItem: React.FunctionComponent<NotificationDra | |||||
onClick={(e) => onClick(e)} | ||||||
onKeyDown={onKeyDown} | ||||||
> | ||||||
<span className="pf-v5-screen-reader">{readStateSRText}</span> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could remove 44-52 and do this
Suggested change
|
||||||
{children} | ||||||
</li> | ||||||
); | ||||||
|
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.
We'll most likely need an
aria-live="polite"
added somewhere, as right now there's no indication that anything has changed when marking a notification as read. Personally I lean a bit more towards adding it to thepf-v5-c-notification-drawer__header-status
element (line ~45 of NotificationDrawerHeader), so that the current count is announced when updated. Doing that would:readStateSRText
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.
@jessiehuff I would be interested in your opinion here as well. I know we talked about a couple of different options.
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.
When testing on VO, I noticed that when I "read" a notification, the screen reader does currently say that specific notification is read. (It looks like from your comment that that was true for you as well. Though it might be wise to check this in other screen readers like JAWS.) If I'm understanding correctly, we're thinking of making the "2 unread" notifications the live region and then updating that text every time a user reads a notification? I suppose that as long as the live region is set to polite, that wouldn't be too bad because then it ideally should let the user get through the notification they're on before informing them of what they have left. I think that could make sense to me.