Skip to content

Commit

Permalink
Change height of composeBox Input when it becomes multiline.
Browse files Browse the repository at this point in the history
In Android onContentSizeChange is called only once
used onChange instead of onContentSizeChange.
(http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native,
facebook/react-native#6552 (comment))

set default height after sending message.
  • Loading branch information
jainkuniya authored and borisyankov committed May 25, 2017
1 parent a7cd388 commit 8297fdc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/compose/ComposeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const MAX_HEIGHT = 200;
const componentStyles = StyleSheet.create({
wrapper: {
flexDirection: 'row',
alignItems: 'center',
},
messageBox: {
flex: 1,
Expand Down Expand Up @@ -73,11 +74,12 @@ class ComposeText extends React.Component {
clearInput = () => {
this.textInput.clear();
this.setState({
text: ''
text: '',
contentHeight: MIN_HEIGHT,
});
}

handleContentSizeChange = (event) =>
handleOnChange = (event) =>
this.setState({ contentHeight: event.nativeEvent.contentSize.height });

handleChangeText = (text: string) => {
Expand Down Expand Up @@ -114,7 +116,7 @@ class ComposeText extends React.Component {
multiline
underlineColorAndroid="transparent"
height={contentHeight}
onContentSizeChange={this.handleContentSizeChange}
onChange={this.handleOnChange}
onChangeText={this.handleChangeText}
placeholder="Type a message here"
/>
Expand Down

0 comments on commit 8297fdc

Please sign in to comment.