Skip to content
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

A11yModule.setKeyboardFocus Not Working on iOS #90

Open
ayushmahajan12 opened this issue Dec 17, 2024 · 3 comments
Open

A11yModule.setKeyboardFocus Not Working on iOS #90

ayushmahajan12 opened this issue Dec 17, 2024 · 3 comments

Comments

@ayushmahajan12
Copy link

The setKeyboardFocus method from the A11yModule is not working on iOS, while it works perfectly on Android. I am attempting to switch focus between two Touchable elements using their ref.

Steps to Reproduce:

  1. Create two TouchableOpacity elements in a React Native app.
  2. Assign ref to each element.
  3. Call A11yModule?.setKeyboardFocus(ref) to switch focus to one of the elements.
  4. Test the behavior on Android and iOS.

Expected Behavior:
Focus should move to the target element on iOS when setKeyboardFocus is called, just as it does on Android.

Actual Behavior:
No focus movement occurs on iOS.

Code

`import { A11yModule } from 'react-native-a11y';
import React, { useRef } from 'react';
import { TouchableOpacity, Text } from 'react-native';

const AccessibilityTest = () => {
const firstItemRef = useRef(null);
const secondItemRef = useRef(null);

const handleSwitchFocus = () => {
    A11yModule?.setKeyboardFocus(firstItemRef);
};

return (
    <>
        <TouchableOpacity ref={firstItemRef}>
            <Text>First Item</Text>
        </TouchableOpacity>
        <TouchableOpacity ref={secondItemRef} onPress={handleSwitchFocus}>
            <Text>Second Item</Text>
        </TouchableOpacity>
    </>
);

};

export default AccessibilityTest;
`

ScreenRecording

ScreenRecording_12-17-2024.18-07-25_1.MP4

Environment:
Library Version: 0.5.6
React Native Version: 0.74.5
iOS Version: 18.1.1
Device/Simulator: Device

Additional Notes:
I have ensured that: ref is correctly assigned.

@ayushmahajan12
Copy link
Author

Hi @ArturKalach , @joonmanji ,

If possible could you please take this on priority.

Thanks in advance :)

@ArturKalach
Copy link
Owner

ArturKalach commented Dec 18, 2024

Hello @ayushmahajan12,
The current solution for physical keyboard focusing on iOS is a bit outdated. It might have some issues with moving focus between different UIViewControllers.

I will try to update the package, but it might take some time. In the meantime, you can try using another package to solve this problem: react-native-external-keyboard. Additionally, it also includes auto-focus and tint color functionality.

There also react-native-a11y-order to controll TalkBack/Voice over order, and react-native-is-keyboard-connected for listening whether a keyboard is connected.


The main idea was to split the library for a better update strategy and package minimization, allowing you to use only specific functionality. It help to release new features, but there are problems with updating this one.

@ayushmahajan12
Copy link
Author

ok Thank you @ArturKalach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants