react-native Talkback宣布TouchableOpacity的accessibilityRole="radio"和accessibilityState "checked"顺序不正确,

fwzugrvs  于 3个月前  发布在  React
关注(0)|答案(5)|浏览(75)

描述

当在 accessibilityRole="radio"accessibilityState={{checked: true}} 上使用 TouchableOpacity 时,Talkback 会宣布 "'checked/not checked', label, 'radio button',"(注意在标签之前先宣布可访问性状态)。在 iOS 上,它会以正确的顺序宣布 "label, checked/not checked)"。

重现步骤

import React, { useCallback, useState } from 'react';
import {
  StyleSheet,
  Text,
  TouchableOpacity,
  View
} from 'react-native';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingHorizontal: 10,
  },
  button: {
    alignItems: 'center',
    backgroundColor: 'yellow',
    opacity: 0.9,
    padding: 10,
    margin: 10
  },
  countContainer: {
    alignItems: 'center',
    padding: 10,
  },
  text: {
    backgroundColor: 'red',
    color: 'yellow',
    padding: 10,
    margin: 10
  },
});

export default function HomeScreen() {
  const [selectedIdx, setSelectedIdx] = useState(-1);
  const onStarSelected = useCallback((idx: any) => setSelectedIdx(idx), []);

  return (
    <View
      accessibilityRole="radiogroup"
      accessibilityLabel="Select rating"
    >
      <TouchableOpacity
        accessibilityRole='radio'
        style={styles.button}
        onPress={() => onStarSelected(1)}
        disabled={selectedIdx === 1}
        accessibilityState={{
          checked: selectedIdx === 1,
        }}
      >
         <Text>1 star</Text>
      </TouchableOpacity>

      <TouchableOpacity
        accessibilityRole='radio'
        style={styles.button}
        onPress={() => onStarSelected(2)}
        disabled={selectedIdx === 2}
        accessibilityState={{
          checked: selectedIdx === 2,
        }}
      >
        <Text>2 stars</Text>
      </TouchableOpacity>

      <TouchableOpacity
        accessibilityRole='radio'
        style={styles.button}
        onPress={() => onStarSelected(3)}
        disabled={selectedIdx === 3}
        accessibilityState={{
          checked: selectedIdx === 3,
        }}
      >
        <Text>3 star</Text>
      </TouchableOpacity>

      <TouchableOpacity
        accessibilityRole='radio'
        style={styles.button}
        onPress={() => onStarSelected(4)}
        disabled={selectedIdx === 4}
        accessibilityState={{
          checked: selectedIdx === 4,
        }}
      >
        <Text>4 stars</Text>
      </TouchableOpacity>

      <TouchableOpacity
        accessibilityRole='radio'
        style={styles.button}
        onPress={() => onStarSelected(5)}
        disabled={selectedIdx === 5}
        accessibilityState={{
          checked: selectedIdx === 5,
        }}
      >
        <Text>5 stars</Text>
      </TouchableOpacity>
    </View>
  );
}

React Native 版本

0.74.2

受影响的平台

运行时 - Android

npx react-native info 的输出

expo-env-info 1.2.0 environment info:
    System:
      OS: macOS 12.7.5
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
      Watchman: 2023.02.13.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.11.3 - /Users/sugi/.gem/ruby/3.1.2/bin/pod
    IDEs:
      Xcode: /undefined - /usr/bin/xcodebuild
    npmPackages:
      expo: ~51.0.14 => 51.0.14
      expo-router: ~3.5.16 => 3.5.16
      react: 18.2.0 => 18.2.0
      react-dom: 18.2.0 => 18.2.0
      react-native: 0.74.2 => 0.74.2
      react-native-web: ~0.19.10 => 0.19.12
    Expo Workflow: managed

堆栈跟踪或日志

N/A

重现器

https://snack.expo.dev/@swidjaja/touchable

截图和视频

  • 无响应*
kb5ga3dv

kb5ga3dv1#

你好!@cortinico 我能解决这个问题吗?

q0qdq0h2

q0qdq0h22#

你好!@cortinico 我可以解决这个问题吗?请做🙏

huus2vyu

huus2vyu3#

你好,@cortinico ,对于安卓设备,我们无法更改Talkback播报顺序("'checked/not checked', label, 'radio button',")。
@swidjaja ,你可以使用accessibilityinfo API进行更多定制。

eblbsuwk

eblbsuwk4#

你好,@cortinico,对于安卓设备,我们无法更改Talkback播报顺序("'checked/not checked', label, 'radio button',")
@swidjaja,你可以使用accessibilityinfo API进行更多定制
@meetdhanani17,谢谢你的回复。你是说使用accessibilityinfo API来改变播报顺序吗?

rslzwgfq

rslzwgfq5#

你好,@cortinico,对于安卓设备,我们无法更改Talkback播报顺序("'checked/not checked', label, 'radio button',")。
@swidjaja,你可以使用accessibilityinfo API进行更多定制。
@meetdhanani17,谢谢你的回复。你是说使用accessibilityinfo API来改变播报顺序吗?
你可以使用它来提供自定义消息,该消息可以与Talkback一起使用。

相关问题