Skip to content

Commit

Permalink
fix: don't warn users about the Keyboard API (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Mar 6, 2024
1 parent 12b8670 commit 83e4620
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ class Keyboard {

constructor() {
if (Platform.isVisionOS) {
warnOnce(
'Keyboard-unavailable',
'Keyboard is not available on visionOS platform. The system displays the keyboard in a separate window, leaving the app’s window unaffected by the keyboard’s appearance and disappearance',
);
return;
}

Expand Down Expand Up @@ -161,6 +157,10 @@ class Keyboard {
context?: mixed,
): EventSubscription {
if (Platform.isVisionOS) {
warnOnce(
'Keyboard-unavailable',
'Keyboard API is not available on visionOS platform. The system displays the keyboard in a separate window, leaving the app’s window unaffected by the keyboard’s appearance and disappearance',
);
return {remove() {}};
}

Expand Down
34 changes: 18 additions & 16 deletions packages/react-native/Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,22 +778,24 @@ class ScrollView extends React.Component<Props, State> {
this._keyboardMetrics = Keyboard.metrics();
this._additionalScrollOffset = 0;

this._subscriptionKeyboardWillShow = Keyboard.addListener(
'keyboardWillShow',
this.scrollResponderKeyboardWillShow,
);
this._subscriptionKeyboardWillHide = Keyboard.addListener(
'keyboardWillHide',
this.scrollResponderKeyboardWillHide,
);
this._subscriptionKeyboardDidShow = Keyboard.addListener(
'keyboardDidShow',
this.scrollResponderKeyboardDidShow,
);
this._subscriptionKeyboardDidHide = Keyboard.addListener(
'keyboardDidHide',
this.scrollResponderKeyboardDidHide,
);
if (Platform.isVisionOS) {
this._subscriptionKeyboardWillShow = Keyboard.addListener(
'keyboardWillShow',
this.scrollResponderKeyboardWillShow,
);
this._subscriptionKeyboardWillHide = Keyboard.addListener(
'keyboardWillHide',
this.scrollResponderKeyboardWillHide,
);
this._subscriptionKeyboardDidShow = Keyboard.addListener(
'keyboardDidShow',
this.scrollResponderKeyboardDidShow,
);
this._subscriptionKeyboardDidHide = Keyboard.addListener(
'keyboardDidHide',
this.scrollResponderKeyboardDidHide,
);
}

this._updateAnimatedNodeAttachment();
}
Expand Down

0 comments on commit 83e4620

Please sign in to comment.