From 509ee8ae97db7350b7693d673ac8f0fcba68f135 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Thu, 7 Jul 2022 11:38:13 +0200 Subject: [PATCH 01/13] Correct accessibility labels for unread rooms in spotlight --- .../dialogs/spotlight/RoomResultDetails.tsx | 9 +- .../dialogs/spotlight/SpotlightDialog.tsx | 83 ++++++++++++++----- 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/components/views/dialogs/spotlight/RoomResultDetails.tsx b/src/components/views/dialogs/spotlight/RoomResultDetails.tsx index 39465b9c735..a0c5535795f 100644 --- a/src/components/views/dialogs/spotlight/RoomResultDetails.tsx +++ b/src/components/views/dialogs/spotlight/RoomResultDetails.tsx @@ -19,10 +19,15 @@ import { Room } from "matrix-js-sdk/src/matrix"; import { roomContextDetailsText, spaceContextDetailsText } from "../../../../utils/i18n-helpers"; -export const RoomResultDetails = ({ room }: { room: Room }) => { +interface Props { + id: string; + room: Room; +} + +export const RoomResultDetails = ({ room, id }: Props) => { const contextDetails = room.isSpaceRoom() ? spaceContextDetailsText(room) : roomContextDetailsText(room); if (contextDetails) { - return
+ return
{ contextDetails }
; } diff --git a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx index 6013b5721f3..2ee2f241f08 100644 --- a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx +++ b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx @@ -63,6 +63,7 @@ import SdkConfig from "../../../../SdkConfig"; import { SettingLevel } from "../../../../settings/SettingLevel"; import SettingsStore from "../../../../settings/SettingsStore"; import { BreadcrumbsStore } from "../../../../stores/BreadcrumbsStore"; +import { RoomNotificationState } from "../../../../stores/notifications/RoomNotificationState"; import { RoomNotificationStateStore } from "../../../../stores/notifications/RoomNotificationStateStore"; import { RecentAlgorithm } from "../../../../stores/room-list/algorithms/tag-sorting/RecentAlgorithm"; import { RoomViewStore } from "../../../../stores/RoomViewStore"; @@ -259,6 +260,22 @@ const findVisibleRoomMembers = (cli: MatrixClient, filterDMs = true) => { ).filter(it => it.userId !== cli.getUserId()); }; +const roomAriaLabel = (room: Room, notification: RoomNotificationState) => { + if (notification.hasMentions) { + return `${room.name} ${_t("%(count)s unread messages including mentions.", { + count: notification.count, + })}`; + } else if (notification.hasUnreadCount) { + return `${room.name} ${_t("%(count)s unread messages.", { + count: notification.count, + })}`; + } else if (notification.isUnread) { + return `${room.name} ${_t("Unread messages.")}`; + } else { + return room.name; + } +}; + interface IDirectoryOpts { limit: number; query: string; @@ -523,6 +540,7 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n if (trimmedQuery || filter !== null) { const resultMapper = (result: Result): JSX.Element => { if (isRoomResult(result)) { + const notification = RoomNotificationStateStore.instance.getRoomState(result.room); return ( ); } if (isMemberResult(result)) { + const label = result.member instanceof RoomMember ? result.member.rawDisplayName : result.member.name; return (