Skip to content

Commit 84b8819

Browse files
committed
improvement: a11y: make "Chats" section a landmark
1 parent 0b9257d commit 84b8819

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

packages/e2e-tests/tests/chat-list-multiselect.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ test.beforeAll(async ({ browser }) => {
5050
page = await browser.newPage()
5151
await reloadPage(page)
5252

53-
chatList = page.getByRole('tablist', { name: 'Chats' })
53+
chatList = page.getByLabel('Chats').getByRole('tablist')
5454
selectedChats = chatList.getByRole('tab', { selected: true })
5555
// Let's stop at 9, so that we don't accidentally select "Chat 10"
5656
// by providing the selector "Chat 1".

packages/frontend/src/components/chat/ChatList.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,16 +495,11 @@ export default function ChatList(props: {
495495
'aria-orientation': 'vertical',
496496
'aria-multiselectable': multiselect != undefined,
497497

498-
// TODO perhaps `pref_` is not nice,
499-
// we might need a separate string.
500-
// The same goes for other occurrences
501-
// of `tx('pref_chats')`.
502498
'aria-labelledby': isSearchActive
503499
? 'search-result-divider-chats'
504500
: undefined,
505-
'aria-label': !isSearchActive
506-
? tx('pref_chats')
507-
: undefined,
501+
// When `!isSearchActive`, the wrapper `<section>` label
502+
// is enough.
508503
}}
509504
isRowLoaded={isChatLoaded}
510505
loadMoreRows={loadChats}

packages/frontend/src/components/screens/MainScreen/MainScreen.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,22 @@ export default function MainScreen({ accountId }: Props) {
230230
!messageSectionShouldBeHidden ? 'chat-view-open' : ''
231231
}`}
232232
>
233-
<section className={styles.chatListAndHeader}>
233+
<section
234+
className={styles.chatListAndHeader}
235+
role='region'
236+
// TODO a11y: reconsider whether it's OK to use the "Chats" label
237+
// even when we're searching for messages in one particular chat
238+
// (`queryChatId`), and even despite the fact
239+
// that search results, besides chats,
240+
// also include messages and contacts.
241+
// For the former, perhaps one could argue that `queryChatId`
242+
// is just a part of the search query.
243+
//
244+
// TODO a11y: perhaps `pref_` is not nice, we might need
245+
// a separate string.
246+
// The same goes for other occurrences of `tx('pref_chats')`.
247+
aria-label={tx('pref_chats')}
248+
>
234249
<section className={styles.chatListHeader} data-tauri-drag-region>
235250
{showArchivedChats && (
236251
<>

0 commit comments

Comments
 (0)