From 008cd469631175583ddab4b6fe7bf58a79b01d73 Mon Sep 17 00:00:00 2001 From: abdurrahmanekr Date: Mon, 27 Nov 2017 11:51:08 +0300 Subject: [PATCH 1/2] maxlength prop added. --- README.md | 1 + src/Input/Input.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 9b646322..2aa38a73 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,7 @@ this.refs.input.clear(); | leftButtons | none | object(component) | left buttons component | | rightButtons | none | object(component) | right buttons component | | inputRef | none | function | input or textarea ref | +| maxlength | none | int | input or textarea maxlength | ## Button Component diff --git a/src/Input/Input.js b/src/Input/Input.js index c6681612..6ad5fc43 100644 --- a/src/Input/Input.js +++ b/src/Input/Input.js @@ -13,6 +13,9 @@ export class Input extends Component { } onChange(e) { + if (this.props.maxlength && (e.target.value || '').length > this.props.maxlength) + return; + this.setState({ value: e.target.value }); @@ -123,6 +126,7 @@ Input.defaultProps = { autoHeight: true, inputStyle: null, inputRef: null, + maxlength: null, }; export default Input; From a1a84c683d759c56f9642c0d231f9ee23cf4de01 Mon Sep 17 00:00:00 2001 From: abdurrahmanekr Date: Mon, 27 Nov 2017 11:53:38 +0300 Subject: [PATCH 2/2] versiyon update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 89406fe0..2fbbb60a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-chat-elements", - "version": "0.7.1", + "version": "0.7.2", "description": "Reactjs chat components", "author": "Avare Kodcu ", "main": "dist/main.js",