Skip to content

Commit

Permalink
fix: resize autogrowing text input back on clear. resize on paste [ch…
Browse files Browse the repository at this point in the history
…17995]
  • Loading branch information
seavan committed Dec 18, 2018
1 parent 9e71a01 commit 6bfb532
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/components/controls/auto-expanding-textinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { observer } from 'mobx-react/native';
import { observable } from 'mobx';
import _ from 'lodash';
import { vars } from '../../styles/styles';
import TextInputUncontrolled from './text-input-uncontrolled';
import { transitionAnimation } from '../helpers/animations';

@observer
export default class AutoExpandingTextInput extends Component {
Expand All @@ -18,17 +20,17 @@ export default class AutoExpandingTextInput extends Component {
}

_onContentSizeChange = event => {
const curHeight = event.nativeEvent.contentSize.height;
if (curHeight < this.props.minHeight || curHeight > this.props.maxHeight) return;
this.height = curHeight;
const { maxHeight, minHeight } = this.props;
this.height = _.clamp(event.nativeEvent.contentSize.height, minHeight, maxHeight);
};

setRef = ref => {
this.textInputRef = ref;
};

clear() {
this.textInputRef.clear();
resetHeight() {
transitionAnimation();
this.height = this.props.minHeight;
}

focus() {
Expand Down
1 change: 1 addition & 0 deletions app/components/layout/input-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class InputMain extends SafeComponent {
if (!this.canSend) return;
this.hasText ? this.props.send(this.value) : this.props.sendAck();
this.value = '';
this.textInputRef.resetHeight();
}
setFocus() {
Expand Down

0 comments on commit 6bfb532

Please sign in to comment.