Skip to content

setAccessibilityFocus not working on screen load #30097

@Logan-Lim

Description

@Logan-Lim

Description

There is an issue with setting accessibility focus on load of a screen. I was able to make it work by calling the function twice in a row.

React Native version:

System:
OS: Windows 10 10.0.19041
CPU: (16) x64 Intel(R) Core(TM) i9-9900KS CPU @ 4.00GHz
Memory: 14.18 GB / 31.93 GB
Binaries:
Node: 12.14.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6626763
Visual Studio: Not Found
Languages:
Java: 13.0.1
Python: 2.7.17
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-39.0.0.tar.gz => 0.63.2
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

  1. Use a callback ref to get an element on screen load
  2. Get the element tag with findNodeHandle
  3. setAccessibilityFocus to the element tag

Expected Results

Accessibility focus should be moved to the desired ref. If I repeat step 3 twice, it will focus correctly, otherwise there is no focus set.

Snack, code example, screenshot, or link to a repository:

Issue raised on StackOverflow: https://stackoverflow.com/questions/63252638/setaccessibilityfocus-using-ref-not-working/
Broken version: https://snack.expo.io/@insats/example-accessibilityinfo-setaccessibilityfocus-not-working
Working version: https://snack.expo.io/@loganlim/example-accessibilityinfo-setaccessibilityfocus-not-working

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions