ArturKalach / react-native-a11y

A11y Library for RN
MIT License
30 stars 2 forks source link

iOS isKeyboardConnected always true #35

Closed consuelo-sanna closed 1 week ago

consuelo-sanna commented 8 months ago

First of all, thank you for this library. I'm using it to detect if the user has the keyboard connected and it works perfectly fine on Android, but I'm having some issues with iOS so I'd like some help - even simply pointing me in the right direction would mean a lot

Basically on iOS isKeyboardConnected always returns true, even if I don't have an external keyboard connected

Has someone ever experienced it? Thanks in advance

ArturKalach commented 8 months ago

Hello @consuelo-sanna,

I appreciate your usage and for reporting issue. I will look into the issue within the next few hours, with the latest resolution expected by the end of this week.

If you are primarily use the 'keyboard is connected' feature, I recommend to check the following library: react-native-is-keyboard-connected.

Furthermore, I have divided the functionality into several libraries, allowing you to use only specific features:

If you have any additional needs, or have any ideas for implementation, feel free to share them here or personaly artur.kalach.andreevich@gmail.com

Sincerely, Artur Kalach

ArturKalach commented 8 months ago

Hello @consuelo-sanna, I have checked isKeyboardConnected functionality on iOS and it works fine on latests versions of the library (0.4.0/0.4.0-rc, 0.3.1).

Could you also share additional information about:

If you have any progress, please share with me, it can help to improve the lib and a11y support in RN.

Sincerely, Artur Kalach

consuelo-sanna commented 8 months ago

Hello @ArturKalach, thank you for your fast response and help, much appreciated!

I tried react-native-is-keyboard-connected and it works directly with this library, I don't know why it behave differently with react-native-a11y (at least that's my experience)

I'm using the following: React Native: "0.71.7" react-native-a11y: 0.3.2 I'm using a Fintie BT keyboard

I'll attach the part of code that was not working, I had no problem with the listener, my only problem was on start and this was the related code:

A11yModule.isKeyboardConnected()
      .then((enabled: boolean) => {
        __DEV__ && console.log('initial keyboard attached: ', enabled);  // ---> always returns true
        // eslint-disable-next-line promise/always-return
        rootStore.appDataStore?.setKeyboardAttached(enabled);
      })
      .catch(() => {
        rootStore?.appDataStore?.setKeyboardAttached(false);
      });

Anyway, as I said before it works with react-native-is-keyboard-connected, so thank you :)

ArturKalach commented 8 months ago

Dear @consuelo-sanna, Sorry for misunderstanding, I thought that you have problem with listeners. I will check this issue in fews days. It is belivable that there are issues with A11yModule.isKeyboardConnected() becouse it poor tested.

Even react-native-a11y will work in some days, but in case you need only the keyboard is connected feature, I would suggest to use react-native-is-keyboard-connected.

Thank you a lot for helping with the issue, your information will help to fix and improve the library, I really appreciate this.

ArturKalach commented 7 months ago

Dear @consuelo-sanna, The A11yModule.isKeyboardConnected has been fixed in the latest version of the lib: 0.4.1 I saw this error previously, but some why didn't fix it here.

Thank you a lot for investigation and helping with issue.

Regards, Artur Kalach

consuelo-sanna commented 3 months ago

Good morning, just so you know I'm seeing a warning about not removing the listeners for the keyboardStatusListener I tried both react-native-is-keyboard-connected and this package, both have the same issue

if I try to manually remove the listeners, TS warns me that

Property 'remove' does not exist on type 'void'

and the warning in the console does not disappear

new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

I'm using the following: React Native: "0.73.2" react-native-a11y: 0.4.3 I'm using a Fintie BT keyboard

Looks like the listener still does work on dev though

ArturKalach commented 3 months ago

Hello @consuelo-sanna, Thank you for information, I will check it in this week.

ArturKalach commented 3 months ago

Hello @consuelo-sanna,

I tested the libs, and found out that there a mistake with types only when I start to write response) There small mistake with types in A11yModule.types.ts.

It should be like this:

A11yModule.types.ts
...
 keyboardStatusListener: (callback: StatusCallback) => () => void;`
...

I will fix it in the next patch, but it can take some time.


What relates to warning....

new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

Honestly, I can't reproduce it... If you have any ideas why it shown or how reproduce please share them.


Thank you a lot for notifying issue, it helps me a lot.

ArturKalach commented 2 months ago

Hello @consuelo-sanna, The type for keyboardStatusListener has been fixed in react-native-a11y: 0.4.4. I will create separate issue for react-native-is-keyboard-connected.

Could you check the issue with required removeListeners method. on v.0.4.4 with such example:

useEffect(() => {
    const removeListener = A11yModule.keyboardStatusListener(e =>
      console.log(e),
    );
    return removeListener;
  }, []);

I suppose any example to reproduce the issue would be also useful for me, could you share the problematic part?

Thank you in advance.

ArturKalach commented 1 week ago

It appears that the issue is no longer reproducing. I am closing it due to the lack of activity and any other potential cases. Please reopen the issue in case of issue reproducing.