Skip to content

Commit e06142f

Browse files
committed
ComposeBox [nfc]: Stop using onLayout listener.
1 parent 72c28a2 commit e06142f

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/compose/ComposeBox.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* @flow strict-local */
22
import React, { PureComponent } from 'react';
33
import { Platform, View, findNodeHandle } from 'react-native';
4-
import type { LayoutEvent } from 'react-native/Libraries/Types/CoreEventTypes';
54
import TextInputReset from 'react-native-text-input-reset';
65
import { type EdgeInsets } from 'react-native-safe-area-context';
76
import { compose } from 'redux';
@@ -93,7 +92,6 @@ type State = {|
9392
isMenuExpanded: boolean,
9493
topic: string,
9594
message: string,
96-
height: number,
9795
selection: InputSelection,
9896
|};
9997

@@ -153,7 +151,6 @@ class ComposeBox extends PureComponent<Props, State> {
153151
isTopicFocused: false,
154152
isFocused: false,
155153
isMenuExpanded: false,
156-
height: 20,
157154
topic: this.props.defaultTopic || '',
158155
message: this.props.defaultMessage || '',
159156
selection: { start: 0, end: 0 },
@@ -225,12 +222,6 @@ class ComposeBox extends PureComponent<Props, State> {
225222
}));
226223
};
227224

228-
handleLayoutChange = (event: LayoutEvent) => {
229-
this.setState({
230-
height: event.nativeEvent.layout.height,
231-
});
232-
};
233-
234225
handleTopicChange = (topic: string) => {
235226
this.setState({ topic, isMenuExpanded: false });
236227
};
@@ -355,7 +346,7 @@ class ComposeBox extends PureComponent<Props, State> {
355346
},
356347
autocompleteWrapper: {
357348
position: 'absolute',
358-
bottom: 0,
349+
bottom: '100%',
359350
width: '100%',
360351
},
361352
composeBox: {
@@ -386,7 +377,7 @@ class ComposeBox extends PureComponent<Props, State> {
386377
};
387378

388379
render() {
389-
const { isTopicFocused, isMenuExpanded, height, message, topic, selection } = this.state;
380+
const { isTopicFocused, isMenuExpanded, message, topic, selection } = this.state;
390381
const {
391382
ownUserId,
392383
narrow,
@@ -422,7 +413,7 @@ class ComposeBox extends PureComponent<Props, State> {
422413
`MentionWarnings` should use a type-checked `connect`
423414
*/}
424415
<MentionWarnings narrow={narrow} stream={stream} ref={this.mentionWarnings} />
425-
<View style={[this.styles.autocompleteWrapper, { marginBottom: height }]}>
416+
<View style={[this.styles.autocompleteWrapper]}>
426417
<TopicAutocomplete
427418
isFocused={isTopicFocused}
428419
narrow={narrow}
@@ -436,7 +427,7 @@ class ComposeBox extends PureComponent<Props, State> {
436427
onAutocomplete={this.handleMessageAutocomplete}
437428
/>
438429
</View>
439-
<View style={[this.styles.composeBox, style]} onLayout={this.handleLayoutChange}>
430+
<View style={[this.styles.composeBox, style]}>
440431
<ComposeMenu
441432
destinationNarrow={this.getDestinationNarrow()}
442433
expanded={isMenuExpanded}

0 commit comments

Comments
 (0)