Skip to content

Commit 83e4620

Browse files
committed
fix: don't warn users about the Keyboard API (#71)
1 parent 12b8670 commit 83e4620

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

packages/react-native/Libraries/Components/Keyboard/Keyboard.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ class Keyboard {
116116

117117
constructor() {
118118
if (Platform.isVisionOS) {
119-
warnOnce(
120-
'Keyboard-unavailable',
121-
'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',
122-
);
123119
return;
124120
}
125121

@@ -161,6 +157,10 @@ class Keyboard {
161157
context?: mixed,
162158
): EventSubscription {
163159
if (Platform.isVisionOS) {
160+
warnOnce(
161+
'Keyboard-unavailable',
162+
'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',
163+
);
164164
return {remove() {}};
165165
}
166166

packages/react-native/Libraries/Components/ScrollView/ScrollView.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -778,22 +778,24 @@ class ScrollView extends React.Component<Props, State> {
778778
this._keyboardMetrics = Keyboard.metrics();
779779
this._additionalScrollOffset = 0;
780780

781-
this._subscriptionKeyboardWillShow = Keyboard.addListener(
782-
'keyboardWillShow',
783-
this.scrollResponderKeyboardWillShow,
784-
);
785-
this._subscriptionKeyboardWillHide = Keyboard.addListener(
786-
'keyboardWillHide',
787-
this.scrollResponderKeyboardWillHide,
788-
);
789-
this._subscriptionKeyboardDidShow = Keyboard.addListener(
790-
'keyboardDidShow',
791-
this.scrollResponderKeyboardDidShow,
792-
);
793-
this._subscriptionKeyboardDidHide = Keyboard.addListener(
794-
'keyboardDidHide',
795-
this.scrollResponderKeyboardDidHide,
796-
);
781+
if (Platform.isVisionOS) {
782+
this._subscriptionKeyboardWillShow = Keyboard.addListener(
783+
'keyboardWillShow',
784+
this.scrollResponderKeyboardWillShow,
785+
);
786+
this._subscriptionKeyboardWillHide = Keyboard.addListener(
787+
'keyboardWillHide',
788+
this.scrollResponderKeyboardWillHide,
789+
);
790+
this._subscriptionKeyboardDidShow = Keyboard.addListener(
791+
'keyboardDidShow',
792+
this.scrollResponderKeyboardDidShow,
793+
);
794+
this._subscriptionKeyboardDidHide = Keyboard.addListener(
795+
'keyboardDidHide',
796+
this.scrollResponderKeyboardDidHide,
797+
);
798+
}
797799

798800
this._updateAnimatedNodeAttachment();
799801
}

0 commit comments

Comments
 (0)