callstack / react-native-visionos

A framework for building native visionOS applications using React
https://callstack.github.io/react-native-visionos-docs/
MIT License
1.02k stars 30 forks source link

Mark `Keyboard` module as unsupported on VisionOS #6

Closed okwasniewski closed 10 months ago

okwasniewski commented 1 year ago

Description

Goal of this issue is to mark Keyboard module as unsupported for VisionOS.

As stated in Apple docs: https://developer.apple.com/documentation/uikit/uikeyboardwillshownotification?language=objc :

An app running in visionOS never receives this notification. The system displays the keyboard in a separate window, leaving the app’s window unaffected by the keyboard’s appearance and disappearance.

Goals:

thiagobrez commented 1 year ago

I can take this one!

thiagobrez commented 1 year ago

@okwasniewski PR #25 is open for review, but I'm getting a memory leak. Probably related to the changes in RCTKeyboardObserver but did not find the culprit yet.

WARN  Sending `didReceiveNetworkData` with no listeners registered.
WARN  Sending `didCompleteNetworkResponse` with no listeners registered.
WARN  Sending `didSendNetworkData` with no listeners registered.
WARN  Sending `didSendNetworkData` with no listeners registered.
WARN  Sending `didSendNetworkData` with no listeners registered.
WARN  Sending `didReceiveNetworkResponse` with no listeners registered.

Will continue investigating, but sending here in case you see something I don't!

TMisiukiewicz commented 1 year ago

@thiagobrez I had the same issue, it was a bug in the core and it was already reverted: https://github.com/facebook/react-native/commit/8ac47faf32dae1744f93dae711b9c92bfe783c23 https://github.com/facebook/react-native/commit/4e04ff5610b0f20c59701920a165c46f21ef2446

thiagobrez commented 1 year ago

Yeah thanks @TMisiukiewicz! @okwasniewski also warned me about it, good to know 🙏🏻

So I'll just wait for it to be synced and re-test

derwaldgeist commented 10 months ago

I actually was confused by the message:

"Keyboard is not available on visionOS platform."

I read this as if React Native visionOS would not support text input at all? Or do you mean that just a certain way to hook into keyboard notifications is unsupported, i.e. to get notified when the keyboard pops up?

okwasniewski commented 10 months ago

I think refining this message as Keyboard API is not available on visionOS platform. would be better. visionOS supports text inputs but doesn't support receiving events and imperatively controlling the keyboard.

I will re-open this issue to take care of this. I also noticed that this pops up when user is not using Keyboard API

derwaldgeist commented 10 months ago

Yes, makes sense. Does this also mean that keyboard events won't work in general? Like to check if the enter key has been pressed in an input field?

okwasniewski commented 10 months ago

@derwaldgeist Keyboard API doesn't handle this. You can use TextInput's onSubmitEditing callback to detect when user pressed the enter (submit key) and it works properly on visionOS.