Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3387027
D14016.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D14016.diff
View Options
diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js
--- a/native/chat/chat-input-bar.react.js
+++ b/native/chat/chat-input-bar.react.js
@@ -345,6 +345,9 @@
+isMessageEdited: (newText?: string) => boolean,
+blockNavigation: () => void,
+onPressJoin: () => void,
+ +setIOSKeyboardHeight: () => void,
+ +showMediaGallery: () => void,
+ +dismissKeyboard: () => void,
};
class ChatInputBar extends React.PureComponent<Props> {
@@ -411,7 +414,7 @@
this.props.hideButtons();
} else if (imageGalleryIsOpen && !imageGalleryWasOpen) {
this.props.expandButtons();
- this.setIOSKeyboardHeight();
+ this.props.setIOSKeyboardHeight();
}
if (
@@ -422,21 +425,6 @@
}
}
- setIOSKeyboardHeight() {
- if (Platform.OS !== 'ios') {
- return;
- }
- const textInput = this.props.textInputRef.current;
- if (!textInput) {
- return;
- }
- const keyboardHeight = getKeyboardHeight();
- if (keyboardHeight === null || keyboardHeight === undefined) {
- return;
- }
- TextInputKeyboardMangerIOS.setKeyboardHeight(textInput, keyboardHeight);
- }
-
render(): React.Node {
const isMember = viewerIsMember(this.props.threadInfo);
let joinButton = null;
@@ -613,13 +601,13 @@
expandoButtonsViewStyle.push({ display: 'none' });
}
return (
- <TouchableWithoutFeedback onPress={this.dismissKeyboard}>
+ <TouchableWithoutFeedback onPress={this.props.dismissKeyboard}>
<View style={this.props.styles.inputContainer}>
<AnimatedView style={this.props.expandoButtonsStyle}>
<View style={expandoButtonsViewStyle}>
{this.props.buttonsExpanded ? expandoButton : null}
<TouchableOpacity
- onPress={this.showMediaGallery}
+ onPress={this.props.showMediaGallery}
activeOpacity={0.4}
>
<AnimatedView style={this.props.cameraRollIconStyle}>
@@ -680,17 +668,6 @@
</TouchableWithoutFeedback>
);
}
-
- showMediaGallery = () => {
- const { keyboardState } = this.props;
- invariant(keyboardState, 'keyboardState should be initialized');
- keyboardState.showMediaGallery(this.props.threadInfo);
- };
-
- dismissKeyboard = () => {
- const { keyboardState } = this.props;
- keyboardState && keyboardState.dismissKeyboard();
- };
}
const joinThreadLoadingStatusSelector = createLoadingStatusSelector(
@@ -1421,6 +1398,30 @@
void dispatchActionPromise(joinThreadActionTypes, joinAction());
}, [dispatchActionPromise, joinAction]);
+ const setIOSKeyboardHeight = React.useCallback(() => {
+ if (Platform.OS !== 'ios') {
+ return;
+ }
+ const textInput = textInputRef.current;
+ if (!textInput) {
+ return;
+ }
+ const keyboardHeight = getKeyboardHeight();
+ if (keyboardHeight === null || keyboardHeight === undefined) {
+ return;
+ }
+ TextInputKeyboardMangerIOS.setKeyboardHeight(textInput, keyboardHeight);
+ }, []);
+
+ const showMediaGallery = React.useCallback(() => {
+ invariant(keyboardState, 'keyboardState should be initialized');
+ keyboardState.showMediaGallery(props.threadInfo);
+ }, [keyboardState, props.threadInfo]);
+
+ const dismissKeyboard = React.useCallback(() => {
+ keyboardState?.dismissKeyboard();
+ }, [keyboardState]);
+
return (
<ChatInputBar
{...props}
@@ -1478,6 +1479,9 @@
isMessageEdited={isMessageEdited}
blockNavigation={blockNavigation}
onPressJoin={onPressJoin}
+ setIOSKeyboardHeight={setIOSKeyboardHeight}
+ showMediaGallery={showMediaGallery}
+ dismissKeyboard={dismissKeyboard}
/>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 7:17 AM (7 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2600089
Default Alt Text
D14016.diff (3 KB)
Attached To
Mode
D14016: [native] Move keyboard handling in ChatInputBar to function component
Attached
Detach File
Event Timeline
Log In to Comment