Skip to content

Commit 76640e8

Browse files
committed
fix: a11y: aria-live for draft quote & attachment
This is handy for the Ctrl + Up shortcut, and also adds confirmation for when using the regular way, i.e. context meny -> reply. Same for attachments.
1 parent 0f2b04e commit 76640e8

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
### Fixed
2020
- message list being empty when double-clicking the chat before it has loaded (again) #4647
2121
- accessibility: improve tab order of the app #4672
22+
- accessibility: announce when the draft's quoted message and attachments change (as a result of user actions) (make it a live region)
2223
- other minor accessibility improvements #4675
2324
- improve performance a little #4512
2425
- fix missing maps.xdc in flatpak build #4682

packages/frontend/src/components/composer/Composer.tsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,34 @@ const Composer = forwardRef<
369369
} else {
370370
return (
371371
<div className='composer' ref={ref}>
372-
<div className='upper-bar'>
372+
<section
373+
// Or should it be 'assetive'? Because it's kind of like
374+
// changing the value of an input.
375+
//
376+
// Keep in mind that this element also changes when switching
377+
// between chats.
378+
// We probably want such changes to be announced still.
379+
aria-live='polite'
380+
// Announce quote / attachment _removals_ as well as text changes
381+
// and node insertions.
382+
aria-relevant='all'
383+
className='upper-bar'
384+
>
373385
{draftState.quote !== null && (
374-
<div className='attachment-quote-section is-quote'>
386+
<div
387+
className='attachment-quote-section is-quote'
388+
// When changing the quoted message, e.g. with the Ctrl + Up
389+
// shortcut, we should read the author's name
390+
// even if it didn't change.
391+
//
392+
// TODO this makes it read the "close" button as well,
393+
// which is not desirable.
394+
//
395+
// TODO is it fine to apply `aria-atomic='true'` to _descendants_
396+
// of `aria-live`, or does it have to be the `aria-live`
397+
// element itself?
398+
aria-atomic='true'
399+
>
375400
<Quote quote={draftState.quote} tabIndex={0} />
376401
<CloseButton onClick={removeQuote} />
377402
</div>
@@ -391,7 +416,7 @@ const Composer = forwardRef<
391416
<CloseButton onClick={removeFile} />
392417
</div>
393418
)}
394-
</div>
419+
</section>
395420
<div className='lower-bar'>
396421
<MenuAttachment
397422
addFileToDraft={addFileToDraft}

0 commit comments

Comments
 (0)