Skip to content

Commit d7fc752

Browse files
Reyhan Ünalabdurrahmanekr
authored andcommitted
add onMaxLengthExceed prop to Input component (#70)
* add onMaxLengthExceed prop to Input component * add description of onMaxLengthExceed
1 parent 394df70 commit d7fc752

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ this.refs.input.clear();
275275
| rightButtons | none | object(component) | right buttons component |
276276
| inputRef | none | function | input or textarea ref |
277277
| maxlength | none | int | input or textarea maxlength |
278+
| onMaxLengthExceed | none | function | called when max length exceed |
278279

279280

280281
## Button Component

src/Input/Input.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ export class Input extends Component {
1313
}
1414

1515
onChange(e) {
16-
if (this.props.maxlength && (e.target.value || '').length > this.props.maxlength)
16+
if (this.props.maxlength && (e.target.value || '').length > this.props.maxlength) {
17+
if (this.props.onMaxLengthExceed instanceof Function)
18+
this.props.onMaxLengthExceed();
1719
return;
20+
}
1821

1922
this.setState({
2023
value: e.target.value
@@ -127,6 +130,7 @@ Input.defaultProps = {
127130
inputStyle: null,
128131
inputRef: null,
129132
maxlength: null,
133+
onMaxLengthExceed: null,
130134
};
131135

132136
export default Input;

0 commit comments

Comments
 (0)