Skip to content

Commit ec248df

Browse files
committed
fix: don't warn users about the Keyboard API (#71)
1 parent e5583a2 commit ec248df

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
@@ -764,22 +764,24 @@ class ScrollView extends React.Component<Props, State> {
764764
this._keyboardMetrics = Keyboard.metrics();
765765
this._additionalScrollOffset = 0;
766766

767-
this._subscriptionKeyboardWillShow = Keyboard.addListener(
768-
'keyboardWillShow',
769-
this.scrollResponderKeyboardWillShow,
770-
);
771-
this._subscriptionKeyboardWillHide = Keyboard.addListener(
772-
'keyboardWillHide',
773-
this.scrollResponderKeyboardWillHide,
774-
);
775-
this._subscriptionKeyboardDidShow = Keyboard.addListener(
776-
'keyboardDidShow',
777-
this.scrollResponderKeyboardDidShow,
778-
);
779-
this._subscriptionKeyboardDidHide = Keyboard.addListener(
780-
'keyboardDidHide',
781-
this.scrollResponderKeyboardDidHide,
782-
);
767+
if (Platform.isVisionOS) {
768+
this._subscriptionKeyboardWillShow = Keyboard.addListener(
769+
'keyboardWillShow',
770+
this.scrollResponderKeyboardWillShow,
771+
);
772+
this._subscriptionKeyboardWillHide = Keyboard.addListener(
773+
'keyboardWillHide',
774+
this.scrollResponderKeyboardWillHide,
775+
);
776+
this._subscriptionKeyboardDidShow = Keyboard.addListener(
777+
'keyboardDidShow',
778+
this.scrollResponderKeyboardDidShow,
779+
);
780+
this._subscriptionKeyboardDidHide = Keyboard.addListener(
781+
'keyboardDidHide',
782+
this.scrollResponderKeyboardDidHide,
783+
);
784+
}
783785

784786
this._updateAnimatedNodeAttachment();
785787
}

0 commit comments

Comments
 (0)