Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions apps/app/src/screens/Denunciar.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,10 @@ export default function Denunciar ({ open, target, onClose, onSent }) {
)
}

// A Pill whose wrapper carries the selection state (Pill sets only
// `disabled` in its own accessibilityState).
// One of two choices: the Pill itself carries the selected state, which a
// wrapping View never gave a screen reader.
function ChoicePill ({ label, selected, onPress }) {
return (
<View accessibilityState={{ selected }}>
<Pill label={label} filled={selected} onPress={onPress} />
</View>
)
return <Pill label={label} filled={selected} selected={selected} onPress={onPress} />
}

// react-native-web drops accessibilityState (aria-checked carries it) and
Expand Down
3 changes: 2 additions & 1 deletion apps/app/src/screens/Publicar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ export default function Publicar ({ open, reply: replyProp, quote = null, moment
{modeSwitch}
{pagesOn({ hosted: node.hosted, accountOrigin: node.accountOrigin }) && roster.length > 0
? (
<View style={styles.asRow} accessibilityRole='radiogroup'>
<View style={styles.asRow} accessibilityRole='radiogroup' accessibilityLabel='Publicar como'>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opcional: o grupo agora tem o nome "Publicar como" e o Text visível logo abaixo repete o mesmo texto, então na web o leitor pode dizer duas vezes. Dá para esconder esse Text do leitor (aria-hidden, ou importantForAccessibility='no' mais accessibilityElementsHidden no nativo).

<Text style={styles.asLabel}>Publicar como</Text>
<Chip label='Você' on={asPage === null} disabled={held} onPress={() => actingStore.me()} />
{roster.map((key) => {
Expand Down Expand Up @@ -2180,6 +2180,7 @@ function Chip ({ label, on, disabled, onPress }) {
accessibilityRole='radio'
accessibilityLabel={label}
accessibilityState={{ checked: on, disabled }}
aria-checked={on}
disabled={disabled}
onPress={onPress}
hitSlop={4}
Expand Down
5 changes: 3 additions & 2 deletions apps/app/src/ui/EmojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ export function EmojiPicker ({ open, onPick }) {
style={styles.search}
/>
{hits === null && (
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.tabs} keyboardShouldPersistTaps='handled'>
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.tabs} keyboardShouldPersistTaps='handled' accessibilityRole='tablist'>
{EMOJI_GROUPS.map((g, i) => (
<Pressable
key={g.label}
accessibilityRole='tab'
accessibilityState={{ selected: i === group }}
aria-selected={i === group}
onPress={() => setGroup(i)}
style={[styles.tab, i === group && styles.tabOn]}
>
Expand All @@ -74,7 +75,7 @@ export function EmojiPicker ({ open, onPick }) {
{/* A new key remounts the grid at the top when its rows change. */}
<ScrollView key={hits ? 'q:' + query.trim() : 'g:' + group} style={styles.scroll} nestedScrollEnabled keyboardShouldPersistTaps='handled'>
{shown.length === 0
? <Text style={styles.empty}>Nenhum emoji encontrado</Text>
? <Text style={styles.empty} accessibilityLiveRegion='polite' aria-live='polite'>Nenhum emoji encontrado</Text>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O ScrollView acima troca de key a cada busca, então este Text é montado já com o texto. Na web, uma região viva inserida junto com o conteúdo costuma não ser anunciada: ela precisa já existir antes de o texto mudar. No iOS, accessibilityLiveRegion não existe. Sugestão: deixe uma região viva sempre montada fora do ScrollView com chave, vazia quando há resultados, e, para o iOS, chame AccessibilityInfo.announceForAccessibility('Nenhum emoji encontrado') quando a busca passa a não ter resultado.

: (
<View style={styles.grid}>
{shown.map((item) => (
Expand Down
8 changes: 5 additions & 3 deletions apps/app/src/ui/Pill.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
// pill that opens a list of choices.
// `maxFontSizeMultiplier` caps the label, for a pill in a Sheet header whose
// other controls are capped. `iconFilled` draws the icon's solid shape (a
// saved star), so the state is not shown by colour alone.
// saved star), so the state is not shown by colour alone. `selected` (a
// boolean) is announced as the pill's selected state, for a pill that is one
// choice of a few (the filled face alone says it to the eye only).

import { Pressable, StyleSheet, Text, View } from 'react-native'
import { PRESSED_OPACITY } from '../pressMotion'
import { Icon } from './Icon'
import { useStyles, useTheme } from './ThemeProvider'
import { layout, type } from './theme'

export function Pill ({ label, icon, iconFilled, iconEnd, onPress, filled, danger, disabled, pending, accessibilityLabel, maxFontSizeMultiplier, tonal, small }) {
export function Pill ({ label, icon, iconFilled, iconEnd, onPress, filled, danger, disabled, pending, accessibilityLabel, maxFontSizeMultiplier, tonal, selected, small }) {
const styles = useStyles(makeStyles)
const { colors } = useTheme()
const iconOnly = typeof label !== 'string' || label === ''
Expand Down Expand Up @@ -44,7 +46,7 @@ export function Pill ({ label, icon, iconFilled, iconEnd, onPress, filled, dange
return (
<Pressable
accessibilityRole='button'
accessibilityState={{ disabled: off }}
accessibilityState={selected === undefined ? { disabled: off } : { disabled: off, selected: selected === true }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No nativo, isso resolve. Na web, o react-native-web descarta accessibilityState (o comentário acima do ReasonRow, em Denunciar.js, diz isso), então "esta publicação" e "a conta toda" continuam mudas lá. Sugestão: com selected definido, passe também aria-pressed={selected === true} neste Pressable, porque num botão o aria-selected não vale. Outra saída é as duas opções virarem radio com aria-checked, como o ReasonRow. Vale um teste para o atributo da web, como os de Chip e das abas.

// A worded pill is read by its label: with an icon beside it a screen
// reader otherwise joined both (", Mensagem").
accessibilityLabel={accessibilityLabel || (iconOnly ? undefined : label)}
Expand Down
35 changes: 35 additions & 0 deletions apps/app/test/a11yCompose.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict'

// Screen reader semantics of Publicar, Denunciar and the emoji panel (#153),
// pinned on the sources like the other composer tests.
const test = require('brittle')
const { readFileSync } = require('node:fs')
const { join } = require('node:path')
const read = (name) => readFileSync(join(__dirname, '../src', name), 'utf8')

test('Pill announces `selected` only for a pill that is one choice of a few', (t) => {
const src = read('ui/Pill.js')
t.ok(src.includes('selected, small }) {'), 'the prop is taken')
t.ok(src.includes('accessibilityState={selected === undefined ? { disabled: off } : { disabled: off, selected: selected === true }}'), 'no selected state unless asked')
})

test('Denunciar: the target choice is announced by the pill, not by a wrapper', (t) => {
const src = read('screens/Denunciar.js')
const choice = src.slice(src.indexOf('function ChoicePill'), src.indexOf('// react-native-web drops accessibilityState'))
t.ok(choice.includes('<Pill label={label} filled={selected} selected={selected} onPress={onPress} />'), 'the Pill carries the state')
t.absent(choice.includes('<View'), 'no wrapping View holds it')
})

test('Publicar: the acting-as radios are one named group and web reads their state', (t) => {
const src = read('screens/Publicar.js')
t.ok(src.includes("<View style={styles.asRow} accessibilityRole='radiogroup' accessibilityLabel='Publicar como'>"), 'the group has a name')
const chip = src.slice(src.indexOf('function Chip ('), src.indexOf('// One attached item'))
t.ok(chip.includes('accessibilityState={{ checked: on, disabled }}') && chip.includes('aria-checked={on}'), 'native and web checked state')
})

test('EmojiPicker: the group tabs sit in a tablist, web reads the selected one and an empty search is announced', (t) => {
const src = read('ui/EmojiPicker.js')
t.ok(src.includes("keyboardShouldPersistTaps='handled' accessibilityRole='tablist'>"), 'the tab row is a tablist')
t.ok(src.includes('accessibilityState={{ selected: i === group }}\n aria-selected={i === group}'), 'native and web selected state')
t.ok(src.includes("<Text style={styles.empty} accessibilityLiveRegion='polite' aria-live='polite'>Nenhum emoji encontrado</Text>"), 'the empty result is a live region')
})
3 changes: 3 additions & 0 deletions docs/changelog/fix-a11y-publicar-denunciar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Corrigido

- Leitor de tela em Publicar, Denunciar e no painel de emojis (PR `fix/a11y-publicar-denunciar`, parte da #153): "esta publicação" e "a conta toda" na denúncia passam a anunciar qual está selecionada; "Publicar como" vira um grupo de opções com nome e o estado marcado também na web; as abas de grupo do painel de emojis formam uma lista de abas com a aba atual anunciada na web, e "Nenhum emoji encontrado" é anunciado ao buscar. Verificação em `docs/verification/fix-a11y-publicar-denunciar.md`.
31 changes: 31 additions & 0 deletions docs/verification/fix-a11y-publicar-denunciar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Leitor de tela em Publicar, Denunciar e no painel de emojis (#153)

Branch `fix/a11y-publicar-denunciar`. Fecha parte da #153: rótulos, papéis e estado selecionado. O que exige leitor de tela num aparelho não foi conferido e segue aberto na issue.

## O que mudou

- `ui/Pill.js` aceita `selected` e o anuncia em `accessibilityState`. Sem a prop, nada muda.
- `screens/Denunciar.js`: "esta publicação" e "a conta toda" deixavam o estado num `View` em volta do botão, que o leitor não lê. Agora o próprio botão carrega `selected`.
- `screens/Publicar.js`: o grupo "Publicar como" ganha o nome, e cada opção ganha `aria-checked` (a web descarta `accessibilityState`).
- `ui/EmojiPicker.js`: a fileira de grupos vira `tablist`, cada aba ganha `aria-selected`, e "Nenhum emoji encontrado" é uma região viva educada.

## Como verificar

A partir da raiz:

- `node apps/app/test/a11yCompose.test.js`
- `node apps/app/test/report.test.js`
- `node apps/app/test/composePolish.test.js`
- `npm run lint`

Caminhada, a fazer com TalkBack (Android) e VoiceOver (iOS), e depois no navegador:

- [ ] Denunciar uma publicação: ao focar "esta publicação" e "a conta toda", o leitor diz qual está selecionada e a seleção muda ao tocar.
- [ ] Publicar como uma Página: o grupo é lido como "Publicar como" e a opção marcada é anunciada.
- [ ] Painel de emojis: as abas são lidas como abas e a atual como selecionada; buscar um texto sem resultado anuncia "Nenhum emoji encontrado".

## Fora desta mudança

- Teste com VoiceOver e TalkBack, e com fonte ampliada (critérios de aceite da #153).
- Foco ao abrir e ao fechar a folha: o `Modal` do React Native cuida disso, sem alteração aqui.
- Alvo de toque de 32 pt das abas de emoji, fora do mínimo de 44 pt: exige mudar o desenho do painel.
Loading