picker icon indicating copy to clipboard operation
picker copied to clipboard

accessibilityLabel for Picker not read by VoiceOver

Open mitchdowney opened this issue 4 years ago • 8 comments

@react-native-picker/picker 1.16.5 iOS 14

I can't get the accessibilityLabel to be read by VoiceOver on an iOS device with a simple Picker example. Instead it is reading the currently selected PickerItem for the focused Picker. Am I doing something wrong? Or does the accessibilityLabel prop on the Picker not get read by VoiceOver?

In the example below I would like the word "hours" read before

In the render:

<Picker
  accessibilityLabel={translate('hours')}
  enabled={!isActive}
  onValueChange={(itemValue) => {
    handleUpdateSleepTimer(itemValue, currentMinute, currentSecond)
  }}
  selectedValue={currentHour}>
  {hourItems}
</Picker>

How the hourItems is defined:

const generatePickerNumberItems = (total: number, key: string) => {
  const arr = [] as any
  for (let i = 0; i < total; i++) {
    arr.push(<Picker.Item key={i + key} label={i.toString()} value={i} />)
  }

  return arr
}

const hourItems = generatePickerNumberItems(24, 'hourItems')

It also seems that I cannot change the accessibilityLabel or accessibilityHint for the PickerItems, so I have no way of announcing to the user this Picker value represents the selected number of hours.

IMG_5013

mitchdowney avatar Aug 21 '21 07:08 mitchdowney

I just updated our app to use @react-native-picker/picker 2.4.0, and I'm still running into this issue. It's making the Sleep Timer in Podverse almost unusable for screen reader users, as we can't announce each individual "hours" "minutes" "seconds" column.

Are we the only ones running into this issue? Other than setting an accessibilityLabel to the <Picker /> component, I'm not sure what else we're supposed to do to make this work.

Also, when I test the iOS Clock app and use its picker for sleep alarms, it reads "5 hours" or "30 minutes"...maybe the accessibilityLabel needs to be added to the Picker.Item rather than the Picker?

mitchdowney avatar Mar 21 '22 02:03 mitchdowney

It looks like accessibility-related props aren't being added to the final picker element at all. This is what I get as the rendered JSX when I was trying to write tests using accessibilityLabel.

Test:

    it("loads a list of songs from the server", async () => {
      const { debug, getByLabelText } = await subject()

      debug("subject output")

      const dropdown = getByLabelText("Pick a song")

      expect(dropdown.children).toHaveLength(songs.length)
    })

Code under test:

  ... //snip
  return (
    <>
      <Text>Pick a song...</Text>
      <Picker accessibilityLabel="Pick a song">
        {listOfSongs}
      </Picker>
    </>
  )

Output of debug() in the test:

     Array [
      <Text>
        Pick a song...
      </Text>,
      <View>
        <RNCPicker
          items={
            Array [
              Object {
                "label": "hello",
                "testID": "hello",
                "textColor": undefined,
                "value": "hello",
              },
              Object {
                "label": "Goodbye",
                "testID": "Goodbye",
                "textColor": undefined,
                "value": "Goodbye",
              },
            ]
          }
          numberOfLines={1}
          onChange={[Function anonymous]}
          selectedIndex={0}
          style={
            Array [
              Object {
                "height": 216,
              },
              undefined,
            ]
          }
          testID="song-picker"
        />
      </View>,
    ]

duraz0rz avatar Jun 26 '22 21:06 duraz0rz

I'm also running into this issue, using the Picker with React Native Windows. Any accessibilityLabel I pass it is not being read by Narrator.

paperbackdragon avatar Jul 20 '22 21:07 paperbackdragon

:tada: This issue has been resolved in version 2.4.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Naturalclar avatar Aug 12 '22 09:08 Naturalclar

@Naturalclar I believe this still might be an issue for iOS, since I only really fixed it for Windows. Would you be able to re-open it?

paperbackdragon avatar Aug 12 '22 17:08 paperbackdragon

Hi @Naturalclar I can confirm that this issue still persists with 2.4.4

ha3 avatar Aug 14 '22 18:08 ha3

Still seeing this on 2.7.5

jaaywags avatar May 31 '24 19:05 jaaywags

Reopening it for iOS

Naturalclar avatar Jun 10 '24 00:06 Naturalclar

Hi, @Naturalclar I'm a blind engineer. I'm using this component in an iOS development, and I can confirm that this issue still persists on this platform. Could you please take a look at it? I would try to fix it, but my Objective C skills are nil. Thanks in advance!

kastwey avatar Aug 25 '24 16:08 kastwey

:tada: This issue has been resolved in version 2.8.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Naturalclar avatar Sep 20 '24 09:09 Naturalclar

@Naturalclar Yeaaaah! ¡Tested with Voice over and it works like a charm! Thanks!!!!!!!!!!!!!

kastwey avatar Oct 27 '24 19:10 kastwey