doc(input): add note about handleChange implementation

old
Simon Selg 2016-08-04 22:02:03 +02:00
parent 6f03fb553a
commit f29e570d29
1 changed files with 3 additions and 1 deletions

View File

@ -82,7 +82,9 @@ const factory = (FontIcon) => {
const { onChange, multiline, maxLength } = this.props;
const valueFromEvent = event.target.value;
// trim value to maxLength if that exists (only on multiline inputs)
// Trim value to maxLength if that exists (only on multiline inputs).
// Note that this is still required even tho we have the onKeyPress filter
// because the user could paste smt in the textarea.
const haveToTrim = (multiline && maxLength && event.target.value.length > maxLength);
const value = haveToTrim ? valueFromEvent.substr(0, maxLength) : valueFromEvent;