Skip to content

Commit a1f6bff

Browse files
committed
ComposeBox [nfc]: Stop using onLayout listener.
1 parent b682b4b commit a1f6bff

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';
@@ -91,7 +90,6 @@ type State = {|
9190
isMenuExpanded: boolean,
9291
topic: string,
9392
message: string,
94-
height: number,
9593
selection: InputSelection,
9694
|};
9795

@@ -148,7 +146,6 @@ class ComposeBox extends PureComponent<Props, State> {
148146
isTopicFocused: false,
149147
isFocused: false,
150148
isMenuExpanded: false,
151-
height: 20,
152149
topic:
153150
this.props.initialTopic !== undefined
154151
? this.props.initialTopic
@@ -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
};
@@ -352,7 +343,7 @@ class ComposeBox extends PureComponent<Props, State> {
352343
},
353344
autocompleteWrapper: {
354345
position: 'absolute',
355-
bottom: 0,
346+
bottom: '100%',
356347
width: '100%',
357348
},
358349
composeBox: {
@@ -383,7 +374,7 @@ class ComposeBox extends PureComponent<Props, State> {
383374
};
384375

385376
render() {
386-
const { isTopicFocused, isMenuExpanded, height, message, topic, selection } = this.state;
377+
const { isTopicFocused, isMenuExpanded, message, topic, selection } = this.state;
387378
const {
388379
ownUserId,
389380
narrow,
@@ -419,7 +410,7 @@ class ComposeBox extends PureComponent<Props, State> {
419410
`MentionWarnings` should use a type-checked `connect`
420411
*/}
421412
<MentionWarnings narrow={narrow} stream={stream} ref={this.mentionWarnings} />
422-
<View style={[this.styles.autocompleteWrapper, { marginBottom: height }]}>
413+
<View style={[this.styles.autocompleteWrapper]}>
423414
<TopicAutocomplete
424415
isFocused={isTopicFocused}
425416
narrow={narrow}
@@ -433,7 +424,7 @@ class ComposeBox extends PureComponent<Props, State> {
433424
onAutocomplete={this.handleMessageAutocomplete}
434425
/>
435426
</View>
436-
<View style={[this.styles.composeBox, style]} onLayout={this.handleLayoutChange}>
427+
<View style={[this.styles.composeBox, style]}>
437428
<ComposeMenu
438429
destinationNarrow={this.getDestinationNarrow()}
439430
expanded={isMenuExpanded}

0 commit comments

Comments
 (0)