diff --git a/apps/app/src/screens/Denunciar.js b/apps/app/src/screens/Denunciar.js index 23fbbc390..6db93787b 100644 --- a/apps/app/src/screens/Denunciar.js +++ b/apps/app/src/screens/Denunciar.js @@ -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 ( - - - - ) + return } // react-native-web drops accessibilityState (aria-checked carries it) and diff --git a/apps/app/src/screens/Publicar.js b/apps/app/src/screens/Publicar.js index e296537fa..01161705c 100644 --- a/apps/app/src/screens/Publicar.js +++ b/apps/app/src/screens/Publicar.js @@ -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 ? ( - + Publicar como actingStore.me()} /> {roster.map((key) => { @@ -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} diff --git a/apps/app/src/ui/EmojiPicker.js b/apps/app/src/ui/EmojiPicker.js index 39536ef3a..c6fd69d31 100644 --- a/apps/app/src/ui/EmojiPicker.js +++ b/apps/app/src/ui/EmojiPicker.js @@ -57,12 +57,13 @@ export function EmojiPicker ({ open, onPick }) { style={styles.search} /> {hits === null && ( - + {EMOJI_GROUPS.map((g, i) => ( setGroup(i)} style={[styles.tab, i === group && styles.tabOn]} > @@ -74,7 +75,7 @@ export function EmojiPicker ({ open, onPick }) { {/* A new key remounts the grid at the top when its rows change. */} {shown.length === 0 - ? Nenhum emoji encontrado + ? Nenhum emoji encontrado : ( {shown.map((item) => ( diff --git a/apps/app/src/ui/Pill.js b/apps/app/src/ui/Pill.js index d89fa9b61..8552d650f 100644 --- a/apps/app/src/ui/Pill.js +++ b/apps/app/src/ui/Pill.js @@ -5,7 +5,9 @@ // 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' @@ -13,7 +15,7 @@ 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 === '' @@ -44,7 +46,7 @@ export function Pill ({ label, icon, iconFilled, iconEnd, onPress, filled, dange return ( 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(''), 'the Pill carries the state') + t.absent(choice.includes(' { + const src = read('screens/Publicar.js') + t.ok(src.includes(""), '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("Nenhum emoji encontrado"), 'the empty result is a live region') +}) diff --git a/docs/changelog/fix-a11y-publicar-denunciar.md b/docs/changelog/fix-a11y-publicar-denunciar.md new file mode 100644 index 000000000..a1d9ffe81 --- /dev/null +++ b/docs/changelog/fix-a11y-publicar-denunciar.md @@ -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`. diff --git a/docs/verification/fix-a11y-publicar-denunciar.md b/docs/verification/fix-a11y-publicar-denunciar.md new file mode 100644 index 000000000..bfbc526ae --- /dev/null +++ b/docs/verification/fix-a11y-publicar-denunciar.md @@ -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.