Repository navigation
fix(app): announce the selected state in report, publish and emoji panel #736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]} | ||
| > | ||
|
|
@@ -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> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. O |
||
| : ( | ||
| <View style={styles.grid}> | ||
| {shown.map((item) => ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 === '' | ||
|
|
@@ -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 }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No nativo, isso resolve. Na web, o react-native-web descarta |
||
| // 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)} | ||
|
|
||
| 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') | ||
| }) |
| 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`. |
| 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. |
There was a problem hiding this comment.
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
Textvisível logo abaixo repete o mesmo texto, então na web o leitor pode dizer duas vezes. Dá para esconder esseTextdo leitor (aria-hidden, ouimportantForAccessibility='no'maisaccessibilityElementsHiddenno nativo).