refactor(input): move autoresize to didUpdate
It needs to be there because it also needs to be called when value is changed from outside by setting the value propertyold
parent
75487fb9a7
commit
8559c1818c
|
@ -69,14 +69,20 @@ const factory = (FontIcon) => {
|
|||
}
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
const { multiline, value } = this.props;
|
||||
|
||||
// resize the textarea, if nessesary
|
||||
if (multiline && (prevProps.value && prevProps.value.length) !== (value && value.length)) {
|
||||
this.handleAutoresize();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
if (this.props.multiline) window.removeEventListener('resize', this.handleAutoresize);
|
||||
}
|
||||
|
||||
handleChange = (event) => {
|
||||
if (this.props.multiline) {
|
||||
this.handleAutoresize();
|
||||
}
|
||||
if (this.props.onChange) this.props.onChange(event.target.value, event);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue