Skip to content

Commit

Permalink
Implement maxLength in Input
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Nov 20, 2020
1 parent d90f6a5 commit 5780cb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DateInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export default class DateInput extends PureComponent {
return;
}

const { value } = input;
const { maxLength, value } = input;
const max = input.getAttribute('max');
const valueNumeric = Number(value);

Expand All @@ -351,7 +351,7 @@ export default class DateInput extends PureComponent {
* However, given 2, smallers possible number would be 20, and thus keeping the focus in
* this field doesn't make sense.
*/
if ((value * 10 > max) || (`${valueNumeric}`.length >= max.length)) {
if ((value * 10 > max) || (`${valueNumeric}`.length >= maxLength)) {
const property = 'nextElementSibling';
const nextInput = findInput(input, property);
focus(nextInput);
Expand Down
1 change: 1 addition & 0 deletions src/DateInput/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default function Input({
disabled={disabled}
inputMode="numeric"
max={max}
maxLength={`${max}`.length}
min={min}
name={name}
onChange={onChange}
Expand Down

0 comments on commit 5780cb5

Please sign in to comment.